Class: Altria::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/altria/scheduler.rb

Constant Summary collapse

CRON_REGEXP =
/\A(\d+|\*) (\d+|\*) (\d+|\*) (\d+|\*) (\d+|\*)\s*\z/

Instance Method Summary collapse

Constructor Details

#initialize(schedule) ⇒ Scheduler

Takes a schedule as a String.



6
7
8
9
# File 'lib/altria/scheduler.rb', line 6

def initialize(schedule)
  @result, @min, @hour, @day, @month, @wday = *schedule.match(CRON_REGEXP)
  validate
end

Instance Method Details

#scheduled?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/altria/scheduler.rb', line 11

def scheduled?
  [:min, :hour, :day, :month, :wday].all? do |key|
    send(key).nil? || send(key) == now.send(key)
  end
end