Class: Scruby::Scheduler
Instance Attribute Summary
Attributes inherited from Ticker
#interval, #loop, #resolution, #size, #start, #tempo, #tick
Instance Method Summary collapse
- #at(tick, &proc) ⇒ Object
- #dispatch ⇒ Object
-
#initialize(opts = {}) ⇒ Scheduler
constructor
A new instance of Scheduler.
Methods inherited from Ticker
#block, #index, #next_time, #run, #running?, #stop
Constructor Details
#initialize(opts = {}) ⇒ Scheduler
Returns a new instance of Scheduler.
75 76 77 78 |
# File 'lib/scruby/ticker.rb', line 75 def initialize opts = {} super @queue = [] end |
Instance Method Details
#at(tick, &proc) ⇒ Object
86 87 88 89 |
# File 'lib/scruby/ticker.rb', line 86 def at tick, &proc @queue[tick] ||= [] @queue[tick].push proc end |
#dispatch ⇒ Object
80 81 82 83 84 |
# File 'lib/scruby/ticker.rb', line 80 def dispatch if blocks = @queue[index] blocks.each{ |b| b.call } end end |