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
Constructors
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 …>
Class methods
Parse a field from a raw header line:
Mail::Field.parse("field-name: field data")
=> #<Mail::Field …>
Instance methods
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.