Class: Frankenpins::TransitionQueue
- Inherits:
-
Object
- Object
- Frankenpins::TransitionQueue
- Defined in:
- lib/frankenpins/transition_queue.rb
Overview
A transition queue Items added to the queue are executed in order
Instance Method Summary collapse
-
#initialize ⇒ TransitionQueue
constructor
A new instance of TransitionQueue.
- #push(transition) ⇒ Object
- #start! ⇒ Object
Constructor Details
#initialize ⇒ TransitionQueue
Returns a new instance of TransitionQueue.
6 7 8 9 |
# File 'lib/frankenpins/transition_queue.rb', line 6 def initialize @queue = Queue.new @debug = false end |
Instance Method Details
#push(transition) ⇒ Object
11 12 13 14 |
# File 'lib/frankenpins/transition_queue.rb', line 11 def push(transition) puts "E: #{transition.type} #{transition}" if @debug @queue.push(transition) end |
#start! ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/frankenpins/transition_queue.rb', line 16 def start! Thread.new do loop do transition = @queue.pop puts "D: #{transition.type} #{transition}" if @debug transition.perform! end end end |