Class: RunApi::Core::ResponseHeaders
- Inherits:
-
Object
- Object
- RunApi::Core::ResponseHeaders
- Includes:
- Enumerable
- Defined in:
- lib/runapi/core/response.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #fetch(key, *fallback, &block) ⇒ Object
-
#initialize(headers = {}) ⇒ ResponseHeaders
constructor
A new instance of ResponseHeaders.
- #key?(key) ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(headers = {}) ⇒ ResponseHeaders
Returns a new instance of ResponseHeaders.
8 9 10 11 |
# File 'lib/runapi/core/response.rb', line 8 def initialize(headers = {}) @headers = {} headers&.each { |key, value| @headers[normalize(key)] = value } end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/runapi/core/response.rb', line 13 def [](key) @headers[normalize(key)] end |
#each(&block) ⇒ Object
25 26 27 |
# File 'lib/runapi/core/response.rb', line 25 def each(&block) @headers.each(&block) end |
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/runapi/core/response.rb', line 29 def empty? @headers.empty? end |
#fetch(key, *fallback, &block) ⇒ Object
17 18 19 |
# File 'lib/runapi/core/response.rb', line 17 def fetch(key, *fallback, &block) @headers.fetch(normalize(key), *fallback, &block) end |
#key?(key) ⇒ Boolean
21 22 23 |
# File 'lib/runapi/core/response.rb', line 21 def key?(key) @headers.key?(normalize(key)) end |
#to_h ⇒ Object
33 34 35 |
# File 'lib/runapi/core/response.rb', line 33 def to_h @headers.dup end |