Sha256: f28d0d96c571d49fcf1c050b3096dbdb4e354f277e0047a8e11775f6cbb09e70
Contents?: true
Size: 856 Bytes
Versions: 3
Compression:
Stored size: 856 Bytes
Contents
require 'em-simple_telnet' require 'logging' require_relative 'response' class Radiodan class MPD class Connection include Logging def initialize(options={}) @port = options[:port] || 6600 @host = options[:host] || 'localhost' end def cmd(command, options={}) options = {match: /^(OK|ACK)/}.merge(options) response = false connect do |c| begin logger.debug command response = c.cmd(command, options).strip rescue Exception => e logger.error "#{command}, #{options} - #{e.to_s}" raise end end Response.new(response, command) end private def connect(&blk) EM::P::SimpleTelnet.new(host: @host, port: @port, prompt: /^(OK|ACK)(.*)$/) do |host| host.waitfor(/^OK MPD \d{1,2}\.\d{1,2}\.\d{1,2}$/) yield(host) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
radiodan-0.0.4 | lib/radiodan/adapter/mpd/connection.rb |
radiodan-0.0.3 | lib/radiodan/adapter/mpd/connection.rb |
radiodan-0.0.2 | lib/radiodan/adapter/mpd/connection.rb |