Class: MPD::Commands::Abstract
- Inherits:
-
Object
- Object
- MPD::Commands::Abstract
- Defined in:
- lib/mpd/commands/abstract.rb
Overview
Base class for MPD commands.
Direct Known Subclasses
AllFiles, ChangeVolume, Consume, Crossfade, CurrentPlaylistAdd, CurrentPlaylistClear, CurrentPlaylistInfo, CurrentPlaylistRemove, CurrentSong, Next, Pause, Ping, Play, PlaylistAdd, PlaylistClear, PlaylistDelete, PlaylistInfo, PlaylistList, PlaylistLoad, PlaylistRemove, PlaylistSave, Previous, Random, Repeat, SetVolume, Single, Status, Stop, Update
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#execute(command) ⇒ Object
This method should be overriden.
-
#initialize(connection: nil, host: 'localhost', port: 6600) ⇒ Abstract
constructor
You can provide you own connection.
Constructor Details
#initialize(connection: nil, host: 'localhost', port: 6600) ⇒ Abstract
You can provide you own connection. It should have same
16 17 18 19 20 21 22 23 24 |
# File 'lib/mpd/commands/abstract.rb', line 16 def initialize(connection: nil, host: 'localhost', port: 6600) @connection = if connection connection else Connection.new(host: host, port: port) .tap(&:connect) .tap(&:gets) end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/mpd/commands/abstract.rb', line 11 def connection @connection end |
Instance Method Details
#execute(command) ⇒ Object
This method should be overriden. Example:
def execute
super('ping')
end
34 35 36 |
# File 'lib/mpd/commands/abstract.rb', line 34 def execute(command) exec_command(command) end |