Class: Grackle::Headers
- Inherits:
-
Object
- Object
- Grackle::Headers
- Includes:
- Enumerable
- Defined in:
- lib/grackle/transport.rb
Overview
:nodoc:
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
- #add(name, value) ⇒ Object
- #add_all(name, values) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Headers
constructor
A new instance of Headers.
- #size ⇒ Object
Constructor Details
#initialize ⇒ Headers
Returns a new instance of Headers.
6 7 8 |
# File 'lib/grackle/transport.rb', line 6 def initialize @data = {} end |
Instance Method Details
#[](name) ⇒ Object
10 11 12 13 |
# File 'lib/grackle/transport.rb', line 10 def [](name) res = @data[name.downcase.to_sym] res ? res.join(",") : nil end |
#[]=(name, value) ⇒ Object
15 16 17 |
# File 'lib/grackle/transport.rb', line 15 def []=(name,value) @data[name.downcase.to_sym] = [value] end |
#add(name, value) ⇒ Object
19 20 21 22 |
# File 'lib/grackle/transport.rb', line 19 def add(name,value) res = (@data[name.downcase.to_sym] ||= []) res << value end |
#add_all(name, values) ⇒ Object
24 25 26 27 |
# File 'lib/grackle/transport.rb', line 24 def add_all(name,values) res = (@data[name.downcase.to_sym] ||= []) res.push(*values) end |
#each ⇒ Object
29 30 31 32 33 |
# File 'lib/grackle/transport.rb', line 29 def each @data.each do |name,value| yield(name.to_s,value.join(",")) end end |
#size ⇒ Object
35 36 37 |
# File 'lib/grackle/transport.rb', line 35 def size @data.size end |