class CronSpec::CronSpecificationFactory
Base class for the definition of CronSpecificationFactory
classes.
Constants
- RangePattern
- SingleValuePattern
- StepPattern
- WildcardPattern
Public Class Methods
new()
click to toggle source
Constructs a new CronSpecificationFactory
# File lib/cron-spec/cron_specification_factory.rb, line 16 def initialize @single_value_pattern = SingleValuePattern @range_pattern = RangePattern @step_pattern = StepPattern end
Public Instance Methods
parse(value_spec)
click to toggle source
Parses a unit of a cron specification. The supported patterns for parsing are one of:
-
Wildcard ‘*’
-
Single Scalar Value [0-9]+|(sun|mon|tue|wed|thu|fri|sat)|(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)
-
Range value (0-9, mon-fri, etc.)
-
Step value (*/[0-9]+)
# File lib/cron-spec/cron_specification_factory.rb, line 31 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
Private Instance Methods
convert_value(value)
click to toggle source
# File lib/cron-spec/cron_specification_factory.rb, line 48 def convert_value(value) value.to_i end