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 |
# File 'lib/rasper_client/client.rb', line 7 def initialize() @host, @port = .values_at(:host, :port) end |
Instance Method Details
#add(options) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rasper_client/client.rb', line 11 def add() symbolize_keys() () response = execute_request(:add, ) JSON.parse(response.body) == { 'success' => true } rescue Errno::ECONNREFUSED raise ConnectionRefusedError end |
#generate(options) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rasper_client/client.rb', line 20 def generate() symbolize_keys() = encode_data() response = execute_request(:generate, ) result = JSON.parse(response.body) Base64.decode64(result['content']) end |