Class: RMail::Header

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

Defined Under Namespace

Classes: Field

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.



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/sup/util.rb', line 150

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