Class: RubstApi::Headers

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rubst_api/http.rb

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ Headers

Returns a new instance of Headers.



10
11
12
# File 'lib/rubst_api/http.rb', line 10

def initialize(values = {})
  @values = values.to_h { |key, value| [key.to_s.downcase.tr("_", "-"), value.to_s] }
end

Instance Method Details

#[](name) ⇒ Object



13
# File 'lib/rubst_api/http.rb', line 13

def [](name) = @values[name.to_s.downcase.tr("_", "-")]

#[]=(name, value) ⇒ Object



14
15
16
# File 'lib/rubst_api/http.rb', line 14

def []=(name, value)
  @values[name.to_s.downcase.tr("_", "-")] = value.to_s
end

#eachObject



17
# File 'lib/rubst_api/http.rb', line 17

def each(&) = @values.each(&)

#to_hObject



18
# File 'lib/rubst_api/http.rb', line 18

def to_h = @values.dup