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.



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/sup/util.rb', line 159

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