Class: MPD::Controller::Commands

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mpd/controller/commands.rb

Defined Under Namespace

Classes: Command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ Commands

Returns a new instance of Commands.



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mpd/controller/commands.rb', line 31

def initialize (controller)
	@controller = controller
	@commands   = []

	controller.do_and_raise_if_needed(:commands).each {|_, name|
		@commands << Command.new(name)
	}

	controller.do_and_raise_if_needed(:notcommands).each {|_, name|
		@commands << Command.new(name, false)
	}
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



29
30
31
# File 'lib/mpd/controller/commands.rb', line 29

def controller
  @controller
end

Instance Method Details

#each(&block) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/mpd/controller/commands.rb', line 44

def each (&block)
	return to_enum unless block_given?

	@commands.each(&block)

	self
end

#inspectObject



52
53
54
# File 'lib/mpd/controller/commands.rb', line 52

def inspect
	"#<#{self.class.name}: #{map {|c| "#{'-' unless c.usable?}#{c.name}"}.join ' '}>"
end