Class: XBMC::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/xbmc/remote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xbmc_address) ⇒ Remote

Returns a new instance of Remote.



7
8
9
# File 'lib/xbmc/remote.rb', line 7

def initialize(xbmc_address)
  self.address = xbmc_address
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



5
6
7
# File 'lib/xbmc/remote.rb', line 5

def address
  @address
end

Instance Method Details

#commandsObject



18
19
20
21
# File 'lib/xbmc/remote.rb', line 18

def commands
  response = HTTParty.get(base_address)
  response["methods"].map { |name, json| "#{name}: #{json["description"]}" }
end

#send_command(method_name, params = {}) ⇒ Object



11
12
13
14
15
16
# File 'lib/xbmc/remote.rb', line 11

def send_command(method_name, params={})
  HTTParty.post(base_address,
    :body => {:id => get_id, :method => method_name, :params => params, :jsonrpc => "2.0",}.to_json,
    :headers => { 'Content-Type' => 'application/json' },
  )
end