Class: CGMiner::API::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cgminer/api/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/cgminer/api/response.rb', line 8

def body
  @body
end

#rawObject (readonly)

Returns the value of attribute raw.



10
11
12
# File 'lib/cgminer/api/response.rb', line 10

def raw
  @raw
end

#statusObject (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_atObject



18
19
20
# File 'lib/cgminer/api/response.rb', line 18

def received_at
  DateTime.strptime("#{@status['When']}", '%s')
end

#success?Boolean

Returns:



22
23
24
# File 'lib/cgminer/api/response.rb', line 22

def success?
  @status['STATUS'] == 'S'
end