Class: Lux::Response::Header

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeader

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

#dataObject (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_hObject



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