Class: Legion::Gaia::NotificationGate::ScheduleEvaluator
- Inherits:
-
Object
- Object
- Legion::Gaia::NotificationGate::ScheduleEvaluator
- Includes:
- Logging::Helper
- Defined in:
- lib/legion/gaia/notification_gate/schedule_evaluator.rb
Constant Summary collapse
- DAY_NAMES =
%w[sun mon tue wed thu fri sat].freeze
- STANDARD_OFFSETS =
Standard (non-DST) offsets for known IANA zone names. Zones that observe DST have two entries; zones that don’t have one.
{ 'America/New_York' => '-05:00', 'America/Chicago' => '-06:00', 'America/Denver' => '-07:00', 'America/Los_Angeles' => '-08:00', 'America/Phoenix' => '-07:00', 'America/Anchorage' => '-09:00', 'Pacific/Honolulu' => '-10:00', 'America/Halifax' => '-04:00', 'America/Toronto' => '-05:00', 'America/Vancouver' => '-08:00', 'UTC' => '+00:00', 'Europe/London' => '+00:00', 'Europe/Paris' => '+01:00', 'Europe/Berlin' => '+01:00', 'Europe/Rome' => '+01:00', 'Europe/Madrid' => '+01:00', 'Europe/Amsterdam' => '+01:00', 'Europe/Stockholm' => '+01:00', 'Europe/Helsinki' => '+02:00', 'Europe/Moscow' => '+03:00', 'Asia/Kolkata' => '+05:30', 'Asia/Tokyo' => '+09:00', 'Asia/Shanghai' => '+08:00', 'Asia/Singapore' => '+08:00', 'Asia/Dubai' => '+04:00', 'Asia/Seoul' => '+09:00', 'Australia/Sydney' => '+10:00', 'Australia/Melbourne' => '+10:00', 'Pacific/Auckland' => '+12:00' }.freeze
- DST_ZONES =
DST adjustments (+1 hour relative to standard) for zones that observe DST.
%w[ America/New_York America/Chicago America/Denver America/Los_Angeles America/Anchorage America/Halifax America/Toronto America/Vancouver Europe/London Europe/Paris Europe/Berlin Europe/Rome Europe/Madrid Europe/Amsterdam Europe/Stockholm Europe/Helsinki Australia/Sydney Australia/Melbourne Pacific/Auckland ].freeze
Instance Method Summary collapse
-
#initialize(schedule: []) ⇒ ScheduleEvaluator
constructor
A new instance of ScheduleEvaluator.
- #quiet?(at: Time.now) ⇒ Boolean
Constructor Details
#initialize(schedule: []) ⇒ ScheduleEvaluator
Returns a new instance of ScheduleEvaluator.
42 43 44 |
# File 'lib/legion/gaia/notification_gate/schedule_evaluator.rb', line 42 def initialize(schedule: []) @schedule = normalize_schedule(schedule) end |
Instance Method Details
#quiet?(at: Time.now) ⇒ Boolean
46 47 48 |
# File 'lib/legion/gaia/notification_gate/schedule_evaluator.rb', line 46 def quiet?(at: Time.now) @schedule.any? { |window| matches_window?(at, window) } end |