class MultiMail::Multimap
Public Class Methods
new()
click to toggle source
# File lib/multi_mail/multimap.rb, line 5 def initialize @hash = {} end
Public Instance Methods
==(other)
click to toggle source
# File lib/multi_mail/multimap.rb, line 18 def ==(other) if Multimap === other @hash == other.hash else @hash == other end end
[](key)
click to toggle source
# File lib/multi_mail/multimap.rb, line 9 def [](key) @hash[key] end
[]=(key, value)
click to toggle source
# File lib/multi_mail/multimap.rb, line 13 def []=(key, value) @hash[key] ||= [] @hash[key] << value end
each_pair() { |key, value| ... }
click to toggle source
# File lib/multi_mail/multimap.rb, line 30 def each_pair @hash.each_pair do |key,values| values.each do |value| yield key, value end end end
merge(other)
click to toggle source
# File lib/multi_mail/multimap.rb, line 38 def merge(other) dup.update(other) end
size()
click to toggle source
# File lib/multi_mail/multimap.rb, line 26 def size @hash.values.flatten.size end
to_hash()
click to toggle source
# File lib/multi_mail/multimap.rb, line 53 def to_hash @hash.dup end
update(other)
click to toggle source
# File lib/multi_mail/multimap.rb, line 42 def update(other) if Multimap === other other.each_pair do |key,value| self[key] = value end else raise ArgumentError end self end
Protected Instance Methods
hash()
click to toggle source
# File lib/multi_mail/multimap.rb, line 59 def hash @hash end