Class: HTTPClient::Header
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(header) ⇒ Header
constructor
A new instance of Header.
- #to_s ⇒ Object
Constructor Details
#initialize(header) ⇒ Header
Returns a new instance of Header.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/rwd/net.rb', line 259 def initialize(header) @header = {} if not header.nil? firstline, rest = header.split(/\r*\n/, 2) @protocol, @code, @text = firstline.split(/ */, 3) @code = @code.to_i if not rest.nil? rest.split(/\r*\n/).each do |line| key, value = line.split(/ /, 2) @header[key.sub(/:$/, "").downcase] = value end end end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
256 257 258 |
# File 'lib/rwd/net.rb', line 256 def code @code end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
254 255 256 |
# File 'lib/rwd/net.rb', line 254 def header @header end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
255 256 257 |
# File 'lib/rwd/net.rb', line 255 def protocol @protocol end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
257 258 259 |
# File 'lib/rwd/net.rb', line 257 def text @text end |
Instance Method Details
#to_s ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/rwd/net.rb', line 278 def to_s res = "" res << "%s %s %s\n" % [@protocol, @code, @text] @header.each do |k, v| res << "%s=%s\n" % [k, v] end return res end |