Class: The86::Client::Response
- Inherits:
-
Object
- Object
- The86::Client::Response
- Defined in:
- lib/the86-client/response.rb
Overview
Representation of an HTTP response.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status, headers, data) ⇒ Response
constructor
status: The numeric HTTP status.
- #links ⇒ Object
Constructor Details
#initialize(status, headers, data) ⇒ Response
status: The numeric HTTP status. headers: Hash of HTTP response headers. data: The decoded body of the response.
9 10 11 12 13 |
# File 'lib/the86-client/response.rb', line 9 def initialize(status, headers, data) @status = status @headers = headers @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
17 18 19 |
# File 'lib/the86-client/response.rb', line 17 def data @data end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
16 17 18 |
# File 'lib/the86-client/response.rb', line 16 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
15 16 17 |
# File 'lib/the86-client/response.rb', line 15 def status @status end |
Instance Method Details
#links ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/the86-client/response.rb', line 20 def links @_links ||= {}.tap do |links| Array(headers["Link"] || headers["link"]).map do |link| link.match %r{\A<([^>]+)>;\s*rel="([^"]+)"\z} end.compact.each do |match| links[match[2].downcase.to_sym] = match[1] end end end |