Class: HttpServer::Table
- Inherits:
-
Object
- Object
- HttpServer::Table
- Includes:
- Enumerable
- Defined in:
- lib/xmlrpc/httpserver.rb
Overview
A case-insensitive Hash class for HTTP header
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each ⇒ Object
-
#initialize(hash = {}) ⇒ Table
constructor
A new instance of Table.
- #update(hash) ⇒ Object
-
#writeTo(port) ⇒ Object
Output the Hash table for the HTTP header.
Constructor Details
#initialize(hash = {}) ⇒ Table
Returns a new instance of Table.
74 75 76 77 |
# File 'lib/xmlrpc/httpserver.rb', line 74 def initialize(hash={}) @hash = hash update(hash) end |
Instance Method Details
#[](key) ⇒ Object
79 80 81 |
# File 'lib/xmlrpc/httpserver.rb', line 79 def [](key) @hash[key.to_s.capitalize] end |
#[]=(key, value) ⇒ Object
83 84 85 |
# File 'lib/xmlrpc/httpserver.rb', line 83 def []=(key, value) @hash[key.to_s.capitalize] = value end |
#each ⇒ Object
92 93 94 |
# File 'lib/xmlrpc/httpserver.rb', line 92 def each @hash.each {|k,v| yield k.capitalize, v } end |
#update(hash) ⇒ Object
87 88 89 90 |
# File 'lib/xmlrpc/httpserver.rb', line 87 def update(hash) hash.each {|k,v| self[k] = v} self end |
#writeTo(port) ⇒ Object
Output the Hash table for the HTTP header
97 98 99 |
# File 'lib/xmlrpc/httpserver.rb', line 97 def writeTo(port) each { |k,v| port << "#{k}: #{v}" << CRLF } end |