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

#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

28
29
30
# File 'lib/mpd/commands/abstract.rb', line 28

def execute(command)
  exec_command(command)
end