Module: MPD::Commands
- Defined in:
- lib/mpd/commands.rb,
lib/mpd/commands/ping.rb,
lib/mpd/commands/play.rb,
lib/mpd/commands/status.rb,
lib/mpd/commands/abstract.rb,
lib/mpd/commands/all_files.rb,
lib/mpd/commands/set_volume.rb,
lib/mpd/commands/current_song.rb,
lib/mpd/commands/change_volume.rb,
lib/mpd/commands/current_playlist_add.rb,
lib/mpd/commands/current_playlist_info.rb,
lib/mpd/commands/current_playlist_remove.rb
Overview
Contains classes representing MPD commands
Defined Under Namespace
Classes: Abstract, AllFiles, ChangeVolume, CurrentPlaylistAdd, CurrentPlaylistInfo, CurrentPlaylistRemove, CurrentSong, Ping, Play, SetVolume, Status
Class Method Summary collapse
-
.define_option_command(class_name, command) ⇒ Object
To define commands like “random <1/0>”.
-
.define_text_argument_command(class_name, command) ⇒ Object
To define commands like ‘save “whatever this is”’.
-
.define_trivial_command(class_name, command) ⇒ Object
To decrease code amount.
Class Method Details
.define_option_command(class_name, command) ⇒ Object
To define commands like “random <1/0>”
37 38 39 40 41 42 43 44 45 |
# File 'lib/mpd/commands.rb', line 37 def self.define_option_command(class_name, command) klass = Class.new(::MPD::Commands::Abstract) do define_method :execute do |state| super(command + state ? ' 1' : ' 0') end end const_set(class_name, klass) end |
.define_text_argument_command(class_name, command) ⇒ Object
To define commands like ‘save “whatever this is”’
24 25 26 27 28 29 30 31 32 |
# File 'lib/mpd/commands.rb', line 24 def self.define_text_argument_command(class_name, command) klass = Class.new(::MPD::Commands::Abstract) do define_method :execute do |arg| super("#{command} \"#{arg}\"") end end const_set(class_name, klass) end |
.define_trivial_command(class_name, command) ⇒ Object
To decrease code amount
11 12 13 14 15 16 17 18 19 |
# File 'lib/mpd/commands.rb', line 11 def self.define_trivial_command(class_name, command) klass = Class.new(::MPD::Commands::Abstract) do define_method :execute do super(command) end end const_set(class_name, klass) end |