Class: MPD::Protocol::CommandList

Inherits:
Object
  • Object
show all
Defined in:
lib/mpd/protocol/command_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(*commands) ⇒ CommandList

Returns a new instance of CommandList.



14
15
16
# File 'lib/mpd/protocol/command_list.rb', line 14

def initialize (*commands)
	@commands = commands.flatten.compact
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/mpd/protocol/command_list.rb', line 22

def method_missing (id, *args, &block)
	if @commands.respond_to? id
		return @commands.__send__ id, *args, &block
	end

	super
end

Instance Method Details

#respond_to_missing?(id, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/mpd/protocol/command_list.rb', line 18

def respond_to_missing? (id, include_private = false)
	@commands.respond_to?(id)
end

#to_aObject



43
44
45
# File 'lib/mpd/protocol/command_list.rb', line 43

def to_a
	@commands
end

#to_sObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mpd/protocol/command_list.rb', line 30

def to_s
	result = StringIO.new

	result.puts 'command_list_ok_begin'
	@commands.each {|command|
		result.puts command.to_s
	}
	result.print 'command_list_end'

	result.seek 0
	result.read
end