Class: Wheneverd::DSL::PeriodParser
- Inherits:
-
Object
- Object
- Wheneverd::DSL::PeriodParser
- Defined in:
- lib/wheneverd/dsl/period_parser.rb
Overview
Converts DSL every(...) period values into trigger objects.
Supported period forms are described in the README.
Uses a strategy pattern to delegate parsing to specialized strategy classes:
- Wheneverd::DSL::PeriodStrategy::DurationStrategy for Duration values
- Wheneverd::DSL::PeriodStrategy::StringStrategy for interval strings and cron expressions
- Wheneverd::DSL::PeriodStrategy::SymbolStrategy for calendar symbols
- Wheneverd::DSL::PeriodStrategy::ArrayStrategy for arrays of calendar symbols
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path:) ⇒ PeriodParser
constructor
A new instance of PeriodParser.
- #trigger_for(period, at:) ⇒ Wheneverd::Trigger::Interval, Wheneverd::Trigger::Calendar
Constructor Details
#initialize(path:) ⇒ PeriodParser
Returns a new instance of PeriodParser.
20 21 22 |
# File 'lib/wheneverd/dsl/period_parser.rb', line 20 def initialize(path:) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/wheneverd/dsl/period_parser.rb', line 17 def path @path end |
Instance Method Details
#trigger_for(period, at:) ⇒ Wheneverd::Trigger::Interval, Wheneverd::Trigger::Calendar
27 28 29 30 31 32 33 |
# File 'lib/wheneverd/dsl/period_parser.rb', line 27 def trigger_for(period, at:) at_times = AtNormalizer.normalize(at, path: path) strategy = PeriodStrategy.for(period, path: path) strategy.parse(period, at_times: at_times) rescue Wheneverd::InvalidIntervalError => e raise InvalidPeriodError.new(e., path: path) end |