Class: RSched::Engine::Sched
- Inherits:
-
Object
- Object
- RSched::Engine::Sched
- Defined in:
- lib/rsched/engine.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(cron, action, sched_start, from = Time.now.to_i, to = Time.now.to_i) ⇒ Sched
constructor
A new instance of Sched.
- #sched(sched_time) ⇒ Object
Constructor Details
#initialize(cron, action, sched_start, from = Time.now.to_i, to = Time.now.to_i) ⇒ Sched
Returns a new instance of Sched.
11 12 13 14 15 16 17 18 19 |
# File 'lib/rsched/engine.rb', line 11 def initialize(cron, action, sched_start, from=Time.now.to_i, to=Time.now.to_i) require 'cron-spec' @tab = CronSpec::CronSpecification.new(cron) @action = action @sched_start = sched_start @queue = [] @last_time = from.to_i / 60 * 60 sched(to) end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
21 22 23 |
# File 'lib/rsched/engine.rb', line 21 def action @action end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
21 22 23 |
# File 'lib/rsched/engine.rb', line 21 def queue @queue end |
Instance Method Details
#sched(sched_time) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rsched/engine.rb', line 23 def sched(sched_time) while @last_time <= sched_time t = Time.at(@last_time).utc if @tab.is_specification_in_effect?(t) time = create_time_key(t) @queue << time if time >= @sched_start end @last_time += 60 end @queue.uniq! end |