Class: Typhoeus::Header
- Inherits:
-
Hash
- Object
- Hash
- Typhoeus::Header
- Defined in:
- lib/typhoeus/header.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
- #dup ⇒ Object
- #fetch(key, *extras) ⇒ Object
-
#initialize(constructor = {}) ⇒ Header
constructor
A new instance of Header.
- #key?(key) ⇒ Boolean
- #merge(hash) ⇒ Object
- #update(other_hash) ⇒ Object (also: #merge!)
Constructor Details
#initialize(constructor = {}) ⇒ Header
Returns a new instance of Header.
3 4 5 6 7 8 9 10 |
# File 'lib/typhoeus/header.rb', line 3 def initialize(constructor = {}) if constructor.is_a?(Hash) super update(constructor) else super(constructor) end end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 |
# File 'lib/typhoeus/header.rb', line 20 def [](key) super(convert_key(key)) end |
#[]=(key, value) ⇒ Object
24 25 26 |
# File 'lib/typhoeus/header.rb', line 24 def []=(key, value) super(convert_key(key), value) end |
#delete(key) ⇒ Object
45 46 47 |
# File 'lib/typhoeus/header.rb', line 45 def delete(key) super(convert_key(key)) end |
#dup ⇒ Object
37 38 39 |
# File 'lib/typhoeus/header.rb', line 37 def dup self.class.new(Marshal.load(Marshal.dump(self))) end |
#fetch(key, *extras) ⇒ Object
12 13 14 |
# File 'lib/typhoeus/header.rb', line 12 def fetch(key, *extras) super(convert_key(key), *extras) end |
#key?(key) ⇒ Boolean
16 17 18 |
# File 'lib/typhoeus/header.rb', line 16 def key?(key) super(convert_key(key)) end |
#merge(hash) ⇒ Object
41 42 43 |
# File 'lib/typhoeus/header.rb', line 41 def merge(hash) self.dup.update(hash) end |
#update(other_hash) ⇒ Object Also known as: merge!
28 29 30 31 32 33 |
# File 'lib/typhoeus/header.rb', line 28 def update(other_hash) other_hash.each_pair do |key, value| self[convert_key(key)] = value end self end |