Class: Wheneverd::DSL::PeriodStrategy::StringStrategy
- Defined in:
- lib/wheneverd/dsl/period_strategy/string_strategy.rb
Overview
Strategy for parsing String period values.
Handles interval strings (e.g., "5m", "1h") and cron expressions.
Constant Summary collapse
- INTERVAL_PATTERN =
/\A-?\d+[smhdw]\z/.freeze
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
12 13 14 |
# File 'lib/wheneverd/dsl/period_strategy/string_strategy.rb', line 12 def handles?(period) period.is_a?(String) end |
#parse(str, at_times:) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/wheneverd/dsl/period_strategy/string_strategy.rb', line 16 def parse(str, at_times:) period_str = str.strip return parse_interval(period_str, at_times: at_times) if interval_string?(period_str) return parse_cron(period_str, at_times: at_times) if cron_string?(period_str) raise_period_error("Unrecognized period #{period_str.inspect}") end |