Class: Wheneverd::DSL::PeriodStrategy::Base
- Inherits:
-
Object
- Object
- Wheneverd::DSL::PeriodStrategy::Base
- Defined in:
- lib/wheneverd/dsl/period_strategy/base.rb
Overview
Base class for period parsing strategies.
Each strategy handles a specific type of period value (Duration, String, Symbol, Array) and converts it into a trigger object.
Direct Known Subclasses
ArrayStrategy, DurationStrategy, StringStrategy, SymbolStrategy
Constant Summary collapse
- DAY_SECONDS =
60 * 60 * 24
- CALENDAR_SYMBOLS =
%i[ hour day month year weekday weekend monday tuesday wednesday thursday friday saturday sunday ].freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#handles?(_period) ⇒ Boolean
Check if this strategy handles the given period type.
-
#initialize(path:) ⇒ Base
constructor
A new instance of Base.
-
#parse(_period, at_times:) ⇒ Wheneverd::Trigger::Interval, Wheneverd::Trigger::Calendar
Parse the period into a trigger.
Constructor Details
#initialize(path:) ⇒ Base
Returns a new instance of Base.
21 22 23 |
# File 'lib/wheneverd/dsl/period_strategy/base.rb', line 21 def initialize(path:) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
18 19 20 |
# File 'lib/wheneverd/dsl/period_strategy/base.rb', line 18 def path @path end |
Instance Method Details
#handles?(_period) ⇒ Boolean
Check if this strategy handles the given period type.
29 30 31 |
# File 'lib/wheneverd/dsl/period_strategy/base.rb', line 29 def handles?(_period) raise NotImplementedError, "#{self.class} must implement #handles?" end |
#parse(_period, at_times:) ⇒ Wheneverd::Trigger::Interval, Wheneverd::Trigger::Calendar
Parse the period into a trigger.
39 40 41 |
# File 'lib/wheneverd/dsl/period_strategy/base.rb', line 39 def parse(_period, at_times:) raise NotImplementedError, "#{self.class} must implement #parse" end |