Class: Dkim::TagValueList
- Inherits:
-
Object
- Object
- Dkim::TagValueList
- Defined in:
- lib/dkim/tag_value_list.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(values = {}) ⇒ TagValueList
constructor
A new instance of TagValueList.
- #to_s ⇒ Object
Constructor Details
#initialize(values = {}) ⇒ TagValueList
Returns a new instance of TagValueList.
3 4 5 6 |
# File 'lib/dkim/tag_value_list.rb', line 3 def initialize values={} @keys = values.keys @values = values.dup end |
Class Method Details
.parse(string) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/dkim/tag_value_list.rb', line 19 def self.parse string list = new string.split(';').each do |keyval| key, value = keyval.split('=', 2) list[key.strip] = value.strip end list end |
Instance Method Details
#[](k) ⇒ Object
12 13 14 |
# File 'lib/dkim/tag_value_list.rb', line 12 def [] k @values[k] end |
#[]=(k, v) ⇒ Object
15 16 17 18 |
# File 'lib/dkim/tag_value_list.rb', line 15 def []= k, v @keys << k unless self[k] @values[k] = v end |
#to_s ⇒ Object
7 8 9 10 11 |
# File 'lib/dkim/tag_value_list.rb', line 7 def to_s @keys.map do |k| "#{k}=#{@values[k]}" end.join('; ') end |