Class: Moc::Controller::Player::Queue

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/moc/controller/player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#controllerObject (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.expand_path(file))

	self
end

#clearObject

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.expand_path(file))

	self
end