Class: RubstApi::Headers
- Inherits:
-
Object
- Object
- RubstApi::Headers
- Includes:
- Enumerable
- Defined in:
- lib/rubst_api/http.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
- #each ⇒ Object
-
#initialize(values = {}) ⇒ Headers
constructor
A new instance of Headers.
- #to_h ⇒ Object
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 |
#each ⇒ Object
17 |
# File 'lib/rubst_api/http.rb', line 17 def each(&) = @values.each(&) |
#to_h ⇒ Object
18 |
# File 'lib/rubst_api/http.rb', line 18 def to_h = @values.dup |