Class: Table

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/action/module/http_pack_helper.rb

Overview

a case-insensitive Hash class for HTTP header

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Table

Returns a new instance of Table.



132
133
134
135
# File 'lib/action/module/http_pack_helper.rb', line 132

def initialize(hash={})
  @hash = hash 
  update(hash)
end

Instance Method Details

#[](key) ⇒ Object



137
138
139
140
# File 'lib/action/module/http_pack_helper.rb', line 137

def [](key)
	# @hash[key.to_s.capitalize]
	@hash[key.to_s]
end

#[]=(key, value) ⇒ Object



142
143
144
145
# File 'lib/action/module/http_pack_helper.rb', line 142

def []=(key, value)
	#@hash[key.to_s.capitalize] = value
	@hash[key.to_s] = value
end

#eachObject



152
153
154
155
# File 'lib/action/module/http_pack_helper.rb', line 152

def each
	#@hash.each {|k,v| yield k.capitalize, v }
	@hash.each {|k,v| yield k, v }
end

#update(hash) ⇒ Object



147
148
149
150
# File 'lib/action/module/http_pack_helper.rb', line 147

def update(hash)
  hash.each {|k,v| self[k] = v}
  self
end

#writeTo(port) ⇒ Object



157
158
159
160
161
# File 'lib/action/module/http_pack_helper.rb', line 157

def writeTo(port)
  each { |k,v|
port << "#{k}: #{v}" << CRLF 
	}
end