Class: RMail::Header

Inherits:
Object show all
Defined in:
lib/sup/util.rb

Instance Method Summary collapse

Instance Method Details

#content_type(default = nil) ⇒ Object

This returns the full content type of this message converted to lower case.

If there is no content type header, returns the passed block is executed and its return value is returned. If no block is passed, the value of the default argument is returned.



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/sup/util.rb', line 128

def content_type(default = nil)
  if value = self['content-type'] and ct = value.strip.split(/\s*;\s*/)[0]
    return ct.downcase
  else
    if block_given?
      yield
    else
      default
    end
  end
end