Class: Response

Inherits:
Object
  • Object
show all
Defined in:
lib/polyphony/http/client/response.rb

Overview

HTTP response

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/polyphony/http/client/response.rb', line 9

def headers
  @headers
end

#status_codeObject (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

#bodyObject



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

#jsonObject



29
30
31
# File 'lib/polyphony/http/client/response.rb', line 29

def json
  @json ||= ::JSON.parse(body)
end

#next_body_chunkObject



25
26
27
# File 'lib/polyphony/http/client/response.rb', line 25

def next_body_chunk
  @adapter.next_body_chunk
end