Class: Unirest::HttpResponse
- Inherits:
-
Object
- Object
- Unirest::HttpResponse
- Defined in:
- lib/unirest/http_response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#raw_body ⇒ Object
readonly
Returns the value of attribute raw_body.
Instance Method Summary collapse
-
#initialize(http_response) ⇒ HttpResponse
constructor
A new instance of HttpResponse.
Constructor Details
#initialize(http_response) ⇒ HttpResponse
Returns a new instance of HttpResponse.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/unirest/http_response.rb', line 35 def initialize(http_response) @code = http_response.code; @headers = http_response.headers @raw_body = http_response @body = @raw_body begin @body = JSON.parse(@raw_body) rescue Exception end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
32 33 34 |
# File 'lib/unirest/http_response.rb', line 32 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
30 31 32 |
# File 'lib/unirest/http_response.rb', line 30 def code @code end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
33 34 35 |
# File 'lib/unirest/http_response.rb', line 33 def headers @headers end |
#raw_body ⇒ Object (readonly)
Returns the value of attribute raw_body.
31 32 33 |
# File 'lib/unirest/http_response.rb', line 31 def raw_body @raw_body end |