Class: Rallet::Client
- Inherits:
-
Object
- Object
- Rallet::Client
- Defined in:
- lib/rallet/client.rb
Defined Under Namespace
Classes: JSONRPCError
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(service_url) ⇒ Client
constructor
A new instance of Client.
-
#request(name, *args) ⇒ Object
Call any method with any args from RPC service.
Constructor Details
#initialize(service_url) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/rallet/client.rb', line 7 def initialize(service_url) @uri = service_url end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/rallet/client.rb', line 5 def uri @uri end |
Instance Method Details
#request(name, *args) ⇒ Object
Call any method with any args from RPC service
12 13 14 15 16 17 18 19 20 |
# File 'lib/rallet/client.rb', line 12 def request(name, *args) if args && index = args.index(nil) args = args[0...index] end request_body = { 'method' => name, 'params' => args, 'id' => 'jsonrpc' }.to_json response = JSON.parse(make_request(request_body)) raise JSONRPCError, response['error'] if response['error'] response['result'] end |