Class: Aitch::Headers
- Inherits:
-
Object
- Object
- Aitch::Headers
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/aitch/headers.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(input = {}) ⇒ Headers
constructor
A new instance of Headers.
- #key?(key) ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(input = {}) ⇒ Headers
Returns a new instance of Headers.
12 13 14 15 |
# File 'lib/aitch/headers.rb', line 12 def initialize(input = {}) @store = {} input.to_h.each {|key, value| self[key] = value } end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 |
# File 'lib/aitch/headers.rb', line 33 def ==(other) @store == Headers.new(other).to_h end |
#[](key) ⇒ Object
21 22 23 |
# File 'lib/aitch/headers.rb', line 21 def [](key) @store[normalize_key(key)] end |
#[]=(key, value) ⇒ Object
25 26 27 |
# File 'lib/aitch/headers.rb', line 25 def []=(key, value) @store[normalize_key(key)] = value end |
#delete(key) ⇒ Object
17 18 19 |
# File 'lib/aitch/headers.rb', line 17 def delete(key) @store.delete(normalize_key(key)) end |
#key?(key) ⇒ Boolean
29 30 31 |
# File 'lib/aitch/headers.rb', line 29 def key?(key) @store.key?(normalize_key(key)) end |
#to_h ⇒ Object
37 38 39 |
# File 'lib/aitch/headers.rb', line 37 def to_h @store.dup end |