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, CurrentPlaylistAdd, CurrentPlaylistInfo, CurrentPlaylistRemove, CurrentSong, Ping, Play, PlaylistAdd, PlaylistInfo, PlaylistList, SetVolume, Status
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 |
# File 'lib/mpd/commands/abstract.rb', line 16 def initialize(connection: nil, host: 'localhost', port: 6600) @connection = connection || Connection.new(host: host, port: port).tap(&:connect).tap(&:gets) 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
28 29 30 |
# File 'lib/mpd/commands/abstract.rb', line 28 def execute(command) exec_command(command) end |