Class: Wheneverd::DSL::PeriodStrategy::DurationStrategy
- Defined in:
- lib/wheneverd/dsl/period_strategy/duration_strategy.rb
Overview
Strategy for parsing Duration period values.
Duration values produce Interval triggers, except for 1.day with at: times which produces a Calendar trigger for daily scheduling.
Constant Summary
Constants inherited from Base
Base::CALENDAR_SYMBOLS, Base::DAY_SECONDS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Wheneverd::DSL::PeriodStrategy::Base
Instance Method Details
#handles?(period) ⇒ Boolean
11 12 13 |
# File 'lib/wheneverd/dsl/period_strategy/duration_strategy.rb', line 11 def handles?(period) period.is_a?(Wheneverd::Duration) end |
#parse(duration, at_times:) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/wheneverd/dsl/period_strategy/duration_strategy.rb', line 15 def parse(duration, at_times:) if at_times.any? return daily_calendar_trigger(at_times) if duration.to_i == DAY_SECONDS raise_period_error("at: is only supported with calendar periods") end interval_trigger(seconds: duration.to_i) end |