Class: Moc::Controller::Player::Queue
- Inherits:
-
Object
- Object
- Moc::Controller::Player::Queue
- Includes:
- Enumerable
- Defined in:
- lib/moc/controller/player.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#add(file) ⇒ Object
add an item to the queue.
-
#clear ⇒ Object
clear the queue.
-
#each(&block) ⇒ Object
iterate over the queued items.
-
#initialize(controller) ⇒ Queue
constructor
A new instance of Queue.
-
#move(from, to) ⇒ Object
swap two items.
-
#remove(file) ⇒ Object
remove an item from the queue.
Constructor Details
#initialize(controller) ⇒ Queue
Returns a new instance of Queue.
19 20 21 |
# File 'lib/moc/controller/player.rb', line 19 def initialize (controller) @controller = controller end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
17 18 19 |
# File 'lib/moc/controller/player.rb', line 17 def controller @controller end |
Instance Method Details
#add(file) ⇒ Object
add an item to the queue
24 25 26 27 28 29 |
# File 'lib/moc/controller/player.rb', line 24 def add (file) controller.send_command :queue_add controller.send_string File.realpath(File.(file)) self end |
#clear ⇒ Object
clear the queue
45 46 47 48 49 |
# File 'lib/moc/controller/player.rb', line 45 def clear controller.send_command :queue_clear self end |
#each(&block) ⇒ Object
iterate over the queued items
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/moc/controller/player.rb', line 52 def each (&block) controller.send_command :get_queue controller.wait_for :data while item = controller.read_item block.call(item) end self end |
#move(from, to) ⇒ Object
swap two items
40 41 42 |
# File 'lib/moc/controller/player.rb', line 40 def move (from, to) self end |
#remove(file) ⇒ Object
remove an item from the queue
32 33 34 35 36 37 |
# File 'lib/moc/controller/player.rb', line 32 def remove (file) controller.send_command :queue_del controller.send_string File.realpath(File.(file)) self end |