Class: MPD::Commands::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/mpd/commands/abstract.rb

Overview

Base class for MPD commands.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject (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