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/playlist_add.rb,
lib/mpd/commands/change_volume.rb,
lib/mpd/commands/playlist_info.rb,
lib/mpd/commands/playlist_list.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, Consume, Crossfade, CurrentPlaylistAdd, CurrentPlaylistClear, CurrentPlaylistInfo, CurrentPlaylistRemove, CurrentSong, Next, Pause, Ping, Play, PlaylistAdd, PlaylistClear, PlaylistDelete, PlaylistInfo, PlaylistList, PlaylistLoad, PlaylistSave, Previous, Random, Repeat, SetVolume, Single, Status, Stop

Class Method Summary collapse

Class Method Details

.define_option_command(class_name, command) ⇒ Object

To define commands like “random <1/0>”


52
53
54
55
56
57
58
59
60
# File 'lib/mpd/commands.rb', line 52

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”'


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

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


15
16
17
18
19
20
21
22
23
# File 'lib/mpd/commands.rb', line 15

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