Method: RMail::Header#fetch_all
- Defined in:
- lib/rmail/header.rb
#fetch_all(name, *rest) ⇒ Object
Returns the values of every field named name
. If there are no such fields, the value returned by the block is returned. If no block is passed, the value of default_value
is returned. If no default_value
is specified, an IndexError exception is raised.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/rmail/header.rb', line 229 def fetch_all name, *rest if rest.length > 1 raise ArgumentError, "wrong # of arguments(#{rest.length + 1} for 2)" end result = select(name) if result.nil? if block_given? yield name elsif rest.length == 1 rest[0] else raise IndexError, 'name not found' end else result.collect { |n, v| v } end end |