module MIME::Headers::MIME

The RFC 2045 MIME message header fields.

Attributes

description[R]
disposition[R]
id[R]
mime_version[R]
transfer_encoding[R]
type[R]

Public Instance Methods

description=(description) click to toggle source

Describes the content, which can be useful for non-MIME clients.

# File lib/mime/headers/mime.rb, line 21
def description= description
  @description = description
  headers.set('Content-Description', description)
end
disposition=(disposition) click to toggle source

Specifies the disposition of the content relative to its enclosing message. Valid values for disposition are inline and attachment. Parameters can also be specified here; see the RFC for details.

RFC 2183 Communicating Presentation Information in Internet Messages.

# File lib/mime/headers/mime.rb, line 33
def disposition= disposition
  @disposition = disposition
  headers.set('Content-Disposition', disposition)
end
id=(id) click to toggle source

Globally unique ID that identifies a top-level message or message entity. Content IDs can be used for referencing or caching purposes.

# File lib/mime/headers/mime.rb, line 42
def id= id
  @id = id
  headers.set('Content-ID', "<#{id}>")
end
mime_version=(version) click to toggle source

Currently only version 1.0 exists.

# File lib/mime/headers/mime.rb, line 65
def mime_version= version
  @mime_version = version
  headers.set('MIME-Version', version)
end
transfer_encoding=(encoding) click to toggle source

The mechanism used for encoding the top-level message content.

Common Encoding Mechanisms

  • 7bit

  • 8bit

  • binary

  • quoted-printable

  • base64

# File lib/mime/headers/mime.rb, line 57
def transfer_encoding= encoding
  @transfer_encoding = encoding
  headers.set('Content-Transfer-Encoding', encoding)
end

Protected Instance Methods

set_disposition(type, params = {}) click to toggle source

type is the disposition type of either “inline” or “attachment”. params is a Hash with zero or more of the following keys:

filename

name of file

creation-date

RFC2822 date-time

modification-date

RFC2822 date-time

read-date

RFC2822 date-time

size

file size in octets

The values for the *-date keys may use Time::rfc2822.

# File lib/mime/headers/mime.rb, line 100
def set_disposition type, params = {}
  if params['filename']
    params['filename'] = File.basename(params['filename'])
  elsif self.respond_to?(:path)
    params['filename'] = File.basename(self.path)
  end
  self.disposition = append_field_params(type, params)
end
type=(type) click to toggle source

Specifies the media type and subtype of the content. type will have the form media-type/subtype.

Common Content Types

  • application/octet-stream

  • audio/mpeg

  • image/jpeg

  • text/plain

  • video/mpeg

# File lib/mime/headers/mime.rb, line 83
def type= type
  @type = type
  headers.set('Content-Type', type)
end