Class: Grackle::Headers

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/grackle/transport.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeHeaders

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

#eachObject



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

#sizeObject



35
36
37
# File 'lib/grackle/transport.rb', line 35

def size
  @data.size
end