class Mhtml::HttpHeader
Constants
- KEY_VALUE_SEP
- VALUE_SEP
Attributes
key[RW]
values[RW]
Public Class Methods
new(key_or_hash, value_lines = nil)
click to toggle source
# File lib/mhtml/http_header.rb, line 10 def initialize(key_or_hash, value_lines = nil) if key_or_hash.is_a?(Hash) @key = key_or_hash[:key] @values = key_or_hash[:values] return end @key = key_or_hash @values = [] values_str = value_lines.join('') values_str.split(VALUE_SEP).each do |val_str| val_str.strip! val = Value.new(val_str) if val.nil? raise "Invalid value:\n#{val_str}\n\nFrom string:\n#{val_str}" end @values << val end end
Public Instance Methods
==(other)
click to toggle source
# File lib/mhtml/http_header.rb, line 33 def ==(other) @key == other.key && @values == other.values end
clone()
click to toggle source
# File lib/mhtml/http_header.rb, line 55 def clone vals = @values.collect { |v| v.clone } HttpHeader.new(key: @key.clone, values: vals) end
to_s()
click to toggle source
following methods are for debugging only - no spec implemented
# File lib/mhtml/http_header.rb, line 51 def to_s "#{@key}#{KEY_VALUE_SEP} #{@values.join(VALUE_SEP + ' ')}" end
value(key)
click to toggle source
# File lib/mhtml/http_header.rb, line 37 def value(key) value = nil @values.each do |v| if v.key == key value = v break end end value end