Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/polyphony/http/client/response.rb
Overview
HTTP response
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
- #body ⇒ Object
- #each_chunk(&block) ⇒ Object
-
#initialize(adapter, status_code, headers) ⇒ Response
constructor
A new instance of Response.
- #json ⇒ Object
- #next_body_chunk ⇒ Object
Constructor Details
#initialize(adapter, status_code, headers) ⇒ Response
Returns a new instance of Response.
11 12 13 14 15 |
# File 'lib/polyphony/http/client/response.rb', line 11 def initialize(adapter, status_code, headers) @adapter = adapter @status_code = status_code @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/polyphony/http/client/response.rb', line 9 def headers @headers end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
9 10 11 |
# File 'lib/polyphony/http/client/response.rb', line 9 def status_code @status_code end |
Instance Method Details
#body ⇒ Object
17 18 19 |
# File 'lib/polyphony/http/client/response.rb', line 17 def body @body ||= @adapter.body end |
#each_chunk(&block) ⇒ Object
21 22 23 |
# File 'lib/polyphony/http/client/response.rb', line 21 def each_chunk(&block) @adapter.each_chunk(&block) end |
#json ⇒ Object
29 30 31 |
# File 'lib/polyphony/http/client/response.rb', line 29 def json @json ||= ::JSON.parse(body) end |
#next_body_chunk ⇒ Object
25 26 27 |
# File 'lib/polyphony/http/client/response.rb', line 25 def next_body_chunk @adapter.next_body_chunk end |