Skip to content

Instantly share code, notes, and snippets.

@mvilrokx
Created December 9, 2012 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvilrokx/4244910 to your computer and use it in GitHub Desktop.
Save mvilrokx/4244910 to your computer and use it in GitHub Desktop.
Siri Proxy Squeezebox plugin: the squeezebox class
class Squeezebox
def initialize(config = {})
puts 'enter initialize in Squeezebox'
@t = Net::Telnet::new(
'Host' => config['host']||'localhost',
'Port' => config['port']||9090,
'Prompt' => /./ # needed to work
)
@id_set = false
@id = self.player('id ?')
@id_set = true
puts 'leave initialize in Squeezebox'
end
def method_missing(method,*args)
args = args * ' '
regex = [method.to_s,args.to_s].join(' ').sub(/\s\?/,'') + '\s\??\s?'
regex = @id_set ? ['(' + @id + ' )?',regex].join(): regex
regex = Regexp.new(regex)
rs = URI.decode(@t.cmd("#{method} #{args}").strip!)
rs.sub!(regex,'')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment