Class: Ecoportal::API::Common::Response
- Inherits:
-
Object
- Object
- Ecoportal::API::Common::Response
- Defined in:
- lib/ecoportal/api/common/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #print ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/ecoportal/api/common/response.rb', line 6 def initialize(response) @status = response.status @body = JSON.parse(response.to_s) rescue nil response.flush end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/ecoportal/api/common/response.rb', line 5 def body @body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/ecoportal/api/common/response.rb', line 5 def status @status end |
Instance Method Details
#print ⇒ Object
14 15 16 17 18 |
# File 'lib/ecoportal/api/common/response.rb', line 14 def print puts "Status: #{@status.code}" puts "Body:" puts JSON.pretty_generate(@body) end |
#success? ⇒ Boolean
11 12 13 |
# File 'lib/ecoportal/api/common/response.rb', line 11 def success? @status.success? end |