Class: Magi::Scheduler
- Inherits:
-
Object
- Object
- Magi::Scheduler
- Defined in:
- lib/magi/scheduler.rb
Constant Summary collapse
- CRON_REGEXP =
/\A(\d+|\*) (\d+|\*) (\d+|\*) (\d+|\*) (\d+|\*)\s*\z/
Instance Method Summary collapse
-
#initialize(schedule) ⇒ Scheduler
constructor
Takes a schedule as a String.
- #scheduled? ⇒ Boolean
Constructor Details
#initialize(schedule) ⇒ Scheduler
Takes a schedule as a String.
6 7 8 9 |
# File 'lib/magi/scheduler.rb', line 6 def initialize(schedule) @result, @min, @hour, @day, @month, @wday = *schedule.match(CRON_REGEXP) validate end |
Instance Method Details
#scheduled? ⇒ Boolean
11 12 13 14 15 |
# File 'lib/magi/scheduler.rb', line 11 def scheduled? [:min, :hour, :day, :month, :wday].all? do |key| send(key).nil? || send(key) == now.send(key) end end |