Class: Lux::Response::Header
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(name) ⇒ Object
-
#initialize ⇒ Header
constructor
A new instance of Header.
- #merge(hash) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Header
Returns a new instance of Header.
5 6 7 |
# File 'lib/lux/response/lib/header.rb', line 5 def initialize @data = {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/lux/response/lib/header.rb', line 3 def data @data end |
Instance Method Details
#[](key) ⇒ Object
9 10 11 |
# File 'lib/lux/response/lib/header.rb', line 9 def [] key @data[key.downcase] end |
#[]=(key, value) ⇒ Object
13 14 15 |
# File 'lib/lux/response/lib/header.rb', line 13 def []= key, value @data[key.downcase] = value end |
#delete(name) ⇒ Object
25 26 27 |
# File 'lib/lux/response/lib/header.rb', line 25 def delete name @data.delete name.downcase end |
#merge(hash) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/lux/response/lib/header.rb', line 17 def merge hash for key, value in hash @data[key.downcase] = value end @data end |
#to_h ⇒ Object
29 30 31 32 |
# File 'lib/lux/response/lib/header.rb', line 29 def to_h # data['Set-Cookie'] = data.delete('set-cookie') if data['set-cookie'] @data#.to_h.sort.to_h end |