Class: CronSpec::CronSpecificationFactory
- Inherits:
-
Object
- Object
- CronSpec::CronSpecificationFactory
- Defined in:
- lib/cron-spec/cron_specification_factory.rb
Direct Known Subclasses
DayFactory, DowFactory, HourFactory, MinuteFactory, MonthFactory
Constant Summary collapse
- WildcardPattern =
/\A\*\z/- SingleValuePattern =
/\A(\d+)\z/- RangePattern =
/\A(\d+)-(\d+)\z/- StepPattern =
/\A\*\/(\d+)\z/
Instance Method Summary collapse
-
#initialize ⇒ CronSpecificationFactory
constructor
A new instance of CronSpecificationFactory.
- #parse(value_spec) ⇒ Object
Constructor Details
#initialize ⇒ CronSpecificationFactory
Returns a new instance of CronSpecificationFactory.
10 11 12 13 14 |
# File 'lib/cron-spec/cron_specification_factory.rb', line 10 def initialize @single_value_pattern = SingleValuePattern @range_pattern = RangePattern @step_pattern = StepPattern end |
Instance Method Details
#parse(value_spec) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cron-spec/cron_specification_factory.rb', line 16 def parse(value_spec) case value_spec when WildcardPattern WildcardCronValue.new(@lower_limit, @upper_limit) when @single_value_pattern SingleValueCronValue.new(@lower_limit, @upper_limit, convert_value($1)) when @range_pattern RangeCronValue.new(@lower_limit, @upper_limit, convert_value($1), convert_value($2)) when @step_pattern StepCronValue.new(@lower_limit, @upper_limit, $1.to_i) else raise "Unrecognized cron specification pattern." end end |