Class: Kodi::RPC
- Inherits:
-
Object
- Object
- Kodi::RPC
- Defined in:
- lib/kodi/RPC.rb
Defined Under Namespace
Classes: JSONRPCError
Instance Method Summary collapse
- #dispatch(name, args = {}) ⇒ Object
-
#initialize(uri) ⇒ RPC
constructor
A new instance of RPC.
Constructor Details
#initialize(uri) ⇒ RPC
Returns a new instance of RPC.
7 8 9 |
# File 'lib/kodi/RPC.rb', line 7 def initialize(uri) @uri = uri end |
Instance Method Details
#dispatch(name, args = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/kodi/RPC.rb', line 11 def dispatch(name, args = {}) post_body = { 'method' => name, 'params' => args, 'jsonrpc' => '2.0', 'id' => '1' }.to_json resp = JSON.parse( http_post_request(post_body) ) raise JSONRPCError, resp['error'] if resp['error'] resp['result'] end |