Class: Philiprehberger::Scheduler::CronParser
- Inherits:
-
Object
- Object
- Philiprehberger::Scheduler::CronParser
- Defined in:
- lib/philiprehberger/scheduler/cron_parser.rb
Constant Summary collapse
- FIELD_RANGES =
[ 0..59, # minute 0..23, # hour 1..31, # day of month 1..12, # month 0..6 # day of week (0 = Sunday) ].freeze
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
Instance Method Summary collapse
-
#initialize(expression) ⇒ CronParser
constructor
A new instance of CronParser.
- #matches?(time) ⇒ Boolean
Constructor Details
#initialize(expression) ⇒ CronParser
Returns a new instance of CronParser.
16 17 18 19 |
# File 'lib/philiprehberger/scheduler/cron_parser.rb', line 16 def initialize(expression) @expression = expression @fields = parse(expression) end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
14 15 16 |
# File 'lib/philiprehberger/scheduler/cron_parser.rb', line 14 def expression @expression end |
Instance Method Details
#matches?(time) ⇒ Boolean
21 22 23 24 |
# File 'lib/philiprehberger/scheduler/cron_parser.rb', line 21 def matches?(time) values = [time.min, time.hour, time.day, time.month, time.wday] @fields.each_with_index.all? { |field, i| field.include?(values[i]) } end |