Class: Requests::Response
- Inherits:
-
Object
- Object
- Requests::Response
- Defined in:
- lib/requests.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#encoding ⇒ Object
TODO Verify that this is based on content-type header.
-
#initialize(status, headers, body) ⇒ Response
constructor
A new instance of Response.
-
#json ⇒ Object
TODO Verify that JSON can parse data without encoding stuff.
-
#text ⇒ Object
TODO this will probably do something related to encoding if necessary.
Constructor Details
#initialize(status, headers, body) ⇒ Response
Returns a new instance of Response.
77 78 79 |
# File 'lib/requests.rb', line 77 def initialize(status, headers, body) @status, @headers, @body = Integer(status), headers, body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
75 76 77 |
# File 'lib/requests.rb', line 75 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
74 75 76 |
# File 'lib/requests.rb', line 74 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
73 74 75 |
# File 'lib/requests.rb', line 73 def status @status end |
Instance Method Details
#encoding ⇒ Object
TODO Verify that this is based on content-type header
87 88 89 |
# File 'lib/requests.rb', line 87 def encoding @body.encoding end |
#json ⇒ Object
TODO Verify that JSON can parse data without encoding stuff
82 83 84 |
# File 'lib/requests.rb', line 82 def json JSON.parse(@body) end |
#text ⇒ Object
TODO this will probably do something related to encoding if necessary
92 93 94 |
# File 'lib/requests.rb', line 92 def text @body end |