Class: UnderFire::APIResponse
- Inherits:
-
Object
- Object
- UnderFire::APIResponse
- Defined in:
- lib/under_fire/api_response.rb
Overview
Wraps query response, providing to_h and to_s methods for easy processing.
Instance Attribute Summary collapse
-
#response ⇒ Hash
readonly
Response as Hash.
Instance Method Summary collapse
-
#initialize(response) ⇒ APIResponse
constructor
A new instance of APIResponse.
-
#success? ⇒ Boolean
Did the query return something?.
-
#to_h ⇒ Hash
Hash representation of response.
-
#to_s ⇒ String
String represenation suitable for command line.
Constructor Details
#initialize(response) ⇒ APIResponse
Returns a new instance of APIResponse.
10 11 12 |
# File 'lib/under_fire/api_response.rb', line 10 def initialize(response) @response = parse_response(response) end |
Instance Attribute Details
#response ⇒ Hash (readonly)
Returns Response as Hash.
7 8 9 |
# File 'lib/under_fire/api_response.rb', line 7 def response @response end |
Instance Method Details
#success? ⇒ Boolean
Returns Did the query return something?.
25 26 27 |
# File 'lib/under_fire/api_response.rb', line 25 def success? response[:responses][:response][:@status] == 'OK' end |
#to_h ⇒ Hash
Returns Hash representation of response.
15 16 17 |
# File 'lib/under_fire/api_response.rb', line 15 def to_h response[:responses] end |
#to_s ⇒ String
Returns String represenation suitable for command line.
20 21 22 |
# File 'lib/under_fire/api_response.rb', line 20 def to_s recursive_to_s(to_h) end |