Class: Nicehash::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/nicehash/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#errorObject (readonly)

Returns the value of attribute error.



34
35
36
# File 'lib/nicehash/client.rb', line 34

def error
  @error
end

#methodObject (readonly)

Returns the value of attribute method.



34
35
36
# File 'lib/nicehash/client.rb', line 34

def method
  @method
end

#resultObject (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

Returns:

  • (Boolean)


49
50
51
# File 'lib/nicehash/client.rb', line 49

def ok?
  @error == nil
end