Class: Postscale::Headers

Inherits:
Object
  • Object
show all
Defined in:
lib/postscale/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/postscale/response.rb', line 5

def headers
  @headers
end

#request_idObject (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_afterObject (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