Class: Postscale::Headers
- Inherits:
-
Object
- Object
- Postscale::Headers
- Defined in:
- lib/postscale/response.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(headers = {}) ⇒ Headers
constructor
A new instance of Headers.
Constructor Details
#initialize(headers = {}) ⇒ Headers
Returns a new instance of Headers.
7 8 9 10 11 12 |
# File 'lib/postscale/response.rb', line 7 def initialize(headers = {}) @headers = {} headers.each { |key, value| @headers[key.to_s] = value } @request_id = self["X-Request-ID"] @retry_after = self["Retry-After"] end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/postscale/response.rb', line 5 def headers @headers end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
5 6 7 |
# File 'lib/postscale/response.rb', line 5 def request_id @request_id end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
5 6 7 |
# File 'lib/postscale/response.rb', line 5 def retry_after @retry_after end |
Instance Method Details
#[](name) ⇒ Object
14 15 16 17 18 |
# File 'lib/postscale/response.rb', line 14 def [](name) lookup = name.to_s.downcase pair = @headers.find { |key, _| key.downcase == lookup } pair && pair[1] end |