Class: CGMiner::API::Response
- Inherits:
-
Object
- Object
- CGMiner::API::Response
- Defined in:
- lib/cgminer/api/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(command_symbol, raw_command_response) ⇒ Response
constructor
A new instance of Response.
- #received_at ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(command_symbol, raw_command_response) ⇒ Response
Returns a new instance of Response.
12 13 14 15 16 |
# File 'lib/cgminer/api/response.rb', line 12 def initialize(command_symbol, raw_command_response) @raw = JSON.parse(raw_command_response) @status = @raw['STATUS'][0] @body = @raw[command_symbol.to_s.upcase] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/cgminer/api/response.rb', line 8 def body @body end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
10 11 12 |
# File 'lib/cgminer/api/response.rb', line 10 def raw @raw end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/cgminer/api/response.rb', line 6 def status @status end |
Instance Method Details
#received_at ⇒ Object
18 19 20 |
# File 'lib/cgminer/api/response.rb', line 18 def received_at DateTime.strptime("#{@status['When']}", '%s') end |
#success? ⇒ Boolean
22 23 24 |
# File 'lib/cgminer/api/response.rb', line 22 def success? @status['STATUS'] == 'S' end |