class

Mail::Field

Inherits Comparable < Reference < Object

Provides a single class to call to create a new structured or unstructured field. Works out per RFC what field of field it is being given and returns the correct field of class back on new.

===Per RFC 2822

2.2. Header Fields

Header fields are lines composed of a field name, followed by a colon
(":"), followed by a field body, and terminated by CRLF.  A field
name MUST be composed of printable US-ASCII characters (i.e.,
characters that have values between 33 and 126, inclusive), except
colon.  A field body may be composed of any US-ASCII characters,
except for CR and LF.  However, a field body may contain CRLF when
used in header "folding" and  "unfolding" as described in section
2.2.3.  All field bodies MUST conform to the syntax described in
sections 3 and 4 of this standard.

Constants

FIELD_NAME_MAP = {"to" => ToField.field_name, "from" => FromField.field_name, "content-transfer-encoding" => ContentTransferEncodingField.field_name, "content-type" => ContentTypeField.field_name}
FIELD_ORDER_LOOKUP = (["return-path", "received", "resent-date", "resent-from", "resent-sender", "resent-to", "resent-cc", "resent-bcc", "resent-message-id", "date", "from", "sender", "reply-to", "to", "cc", "bcc", "message-id", "in-reply-to", "references", "subject", "comments", "keywords", "mime-version", "content-type", "content-transfer-encoding", "content-location", "content-disposition", "content-description"] of ::String).each_with_index.to_h
FIELDS_MAP = {"to" => ToField, "from" => FromField, "content-transfer-encoding" => ContentTransferEncodingField, "content-type" => ContentTypeField}
KNOWN_FIELDS = STRUCTURED_FIELDS + ["comments", "subject"]
STRUCTURED_FIELDS = ["bcc", "cc", "content-description", "content-disposition", "content-id", "content-location", "content-transfer-encoding", "content-type", "date", "from", "in-reply-to", "keywords", "message-id", "mime-version", "received", "references", "reply-to", "resent-bcc", "resent-cc", "resent-date", "resent-from", "resent-message-id", "resent-sender", "resent-to", "return-path", "sender", "to"] of ::String

Constructors

new(name, value = nil, charset = "UTF-8")

Create a field by name and optional value:

Mail::Field.new("field-name", "value")

=> #<Mail::Field …>

Values that aren't strings or arrays are coerced to Strings with #to_s.

Mail::Field.new("field-name", 1234)

=> #<Mail::Field …>

Mail::Field.new('content-type', ['text', 'plain', {:charset => 'UTF-8'}])

=> #<Mail::Field …>

Source

Class methods

parse(field : String, charset = "UTF-8")

Parse a field from a raw header line:

Mail::Field.parse("field-name: field data")

=> #<Mail::Field …>

Source
split(raw_field)
Source

Instance methods

<=>(other)
Source
==(other)

Returns false (other can only be a Value here).

Source
field
Source
field=(field : Mail::CommonField | Nil)
Source
field_order_id
Source
name
Source
responsible_for?(field_name)
Source
same(other)
Source
to_s

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.

Source
unparsed_value
Source
unparsed_value=(unparsed_value : String | Nil)
Source
value
Source
value=(val)
Source

Macros

method_missing(call)
Source
process_fields_name_map
Source

Nested types