Class: Mhtml::HttpHeader::Value
- Inherits:
-
Object
- Object
- Mhtml::HttpHeader::Value
- Defined in:
- lib/mhtml/http_header.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #clone ⇒ Object
-
#initialize(str_or_hash) ⇒ Value
constructor
str examples: value key=“value”.
-
#to_s ⇒ Object
following methods are for debugging only - no spec implemented.
Constructor Details
#initialize(str_or_hash) ⇒ Value
str examples: value key=“value”
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# 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 |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
61 62 63 |
# File 'lib/mhtml/http_header.rb', line 61 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
61 62 63 |
# File 'lib/mhtml/http_header.rb', line 61 def value @value end |
Instance Method Details
#==(other) ⇒ Object
85 86 87 |
# File 'lib/mhtml/http_header.rb', line 85 def ==(other) @key == other.key && @value == other.value end |
#clone ⇒ Object
98 99 100 |
# File 'lib/mhtml/http_header.rb', line 98 def clone Value.new(key: @key.clone, value: @value.clone) end |
#to_s ⇒ Object
following methods are for debugging only - no spec implemented
90 91 92 93 94 95 96 |
# File 'lib/mhtml/http_header.rb', line 90 def to_s if @key.nil? @value else %Q[#{@key}="#{@value}"] end end |