Class: RasperClient::Client
- Inherits:
-
Object
- Object
- RasperClient::Client
- Defined in:
- lib/rasper_client/client.rb
Instance Method Summary collapse
- #add(options) ⇒ Object
- #generate(options) ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/rasper_client/client.rb', line 7 def initialize() @host, @port, @timeout = .values_at(:host, :port, :timeout) @request_params = build_request_params end |
Instance Method Details
#add(options) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/rasper_client/client.rb', line 12 def add() symbolize_keys() () response = execute_request(:add, ) JSON.parse(response.body) == { 'success' => true } rescue Errno::ECONNREFUSED raise ConnectionRefusedError end |
#generate(options) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rasper_client/client.rb', line 21 def generate() symbolize_keys() = encode_data() response = execute_request(:generate, ) result = JSON.parse(response.body) Base64.decode64(result['content']) end |