Class: Atomsphere::Api::Response
- Inherits:
-
Object
- Object
- Atomsphere::Api::Response
- Defined in:
- lib/atomsphere/api/response.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(request, response) ⇒ Response
constructor
A new instance of Response.
- #to_hash ⇒ Object
Constructor Details
#initialize(request, response) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 |
# File 'lib/atomsphere/api/response.rb', line 8 def initialize(request, response) @request = request @response = response @code = response.nil? ? nil : response.code.to_i @message = response.nil? ? nil : response. end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/atomsphere/api/response.rb', line 6 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/atomsphere/api/response.rb', line 6 def @message end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/atomsphere/api/response.rb', line 6 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/atomsphere/api/response.rb', line 6 def response @response end |
Instance Method Details
#to_hash ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/atomsphere/api/response.rb', line 15 def to_hash begin JSON.parse @response.body rescue JSON::ParserError @response.body end if @response end |