Class: ChimeraHttpClient::Response
- Inherits:
-
Object
- Object
- ChimeraHttpClient::Response
- Defined in:
- lib/chimera_http_client/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #parsed_body ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 |
# File 'lib/chimera_http_client/response.rb', line 5 def initialize(response) @body = response.body @code = response.code @time = response.total_time @response = response # contains the request end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/chimera_http_client/response.rb', line 3 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/chimera_http_client/response.rb', line 3 def code @code end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/chimera_http_client/response.rb', line 3 def response @response end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/chimera_http_client/response.rb', line 3 def time @time end |
Instance Method Details
#error? ⇒ Boolean
18 19 20 |
# File 'lib/chimera_http_client/response.rb', line 18 def error? false end |
#parsed_body ⇒ Object
12 13 14 15 16 |
# File 'lib/chimera_http_client/response.rb', line 12 def parsed_body JSON.parse(body) rescue JSON::ParserError => e raise ChimeraHttpClient::JsonParserError, "Could not parse body as JSON: #{body}, error: #{e.}" end |