Class: Nicehash::Response
- Inherits:
-
Object
- Object
- Nicehash::Response
- Defined in:
- lib/nicehash/client.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method, result = nil, error = nil) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
Constructor Details
#initialize(method, result = nil, error = nil) ⇒ Response
Returns a new instance of Response.
43 44 45 46 47 |
# File 'lib/nicehash/client.rb', line 43 def initialize(method, result = nil, error = nil) @method = method @result = result @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
34 35 36 |
# File 'lib/nicehash/client.rb', line 34 def error @error end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
34 35 36 |
# File 'lib/nicehash/client.rb', line 34 def method @method end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
34 35 36 |
# File 'lib/nicehash/client.rb', line 34 def result @result end |
Class Method Details
.from_faraday_resp(resp) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/nicehash/client.rb', line 36 def self.from_faraday_resp(resp) body = resp.body error = body&.dig(:result, :error) result = error ? nil : body[:result] self.new(body[:method], result, error) end |
Instance Method Details
#ok? ⇒ Boolean
49 50 51 |
# File 'lib/nicehash/client.rb', line 49 def ok? @error == nil end |