Class: Bubbles::CommandQueue
- Inherits:
-
Object
- Object
- Bubbles::CommandQueue
- Extended by:
- Forwardable
- Defined in:
- lib/bubbles/command_queue.rb
Instance Method Summary collapse
- #<<(command_object) ⇒ Object
- #call_next ⇒ Object
-
#initialize(config:) ⇒ CommandQueue
constructor
A new instance of CommandQueue.
- #inspect ⇒ Object
- #queue ⇒ Object
- #reschedule(command_object) ⇒ Object
Constructor Details
#initialize(config:) ⇒ CommandQueue
Returns a new instance of CommandQueue.
7 8 9 |
# File 'lib/bubbles/command_queue.rb', line 7 def initialize(config:) @config = config end |
Instance Method Details
#<<(command_object) ⇒ Object
15 16 17 |
# File 'lib/bubbles/command_queue.rb', line 15 def <<(command_object) queue << command_object end |
#call_next ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bubbles/command_queue.rb', line 19 def call_next if command = queue.shift log command command.call else log "Nothing in the command queue" end end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/bubbles/command_queue.rb', line 32 def inspect "<##{self.class.name} queue:#{queue.inspect} >" end |
#queue ⇒ Object
11 12 13 |
# File 'lib/bubbles/command_queue.rb', line 11 def queue @queue ||= [] end |
#reschedule(command_object) ⇒ Object
28 29 30 |
# File 'lib/bubbles/command_queue.rb', line 28 def reschedule(command_object) queue.unshift(command_object) end |