class Mhtml::HttpHeader::Value

Attributes

key[R]
value[R]

Public Class Methods

new(str_or_hash) click to toggle source

str examples: value key=“value”

# File lib/mhtml/http_header.rb, line 66
def initialize(str_or_hash)
  if str_or_hash.is_a?(Hash)
    @key = str_or_hash[:key]
    @value = str_or_hash[:value]
    return
  end

  str = str_or_hash
  split_i = str.index('=')
  @key = str[0, split_i].strip unless split_i.nil?

  @value = 
  if split_i.nil?
    str.strip
  else
    str[split_i + 1, str.length - 1].strip.strip_other('"')
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/mhtml/http_header.rb, line 85
def ==(other)
  @key == other.key && @value == other.value
end
clone() click to toggle source
# File lib/mhtml/http_header.rb, line 98
def clone
  Value.new(key: @key.clone, value: @value.clone)
end
to_s() click to toggle source

following methods are for debugging only - no spec implemented

# File lib/mhtml/http_header.rb, line 90
def to_s
  if @key.nil?
    @value
  else
    %Q[#{@key}="#{@value}"]
  end
end