Class: Mail::UnstructuredField
- Inherits:
-
CommonField
- Object
- CommonField
- Mail::UnstructuredField
- Defined in:
- lib/mail/fields/unstructured_field.rb
Overview
Provides access to an unstructured header field
Per RFC 2822:
2.2.1. Unstructured Header Field Bodies
Some field bodies in this standard are defined simply as
"unstructured" (which is specified below as any US-ASCII characters,
except for CR and LF) with no further restrictions. These are
referred to as unstructured field bodies. Semantically, unstructured
field bodies are simply to be treated as a single line of characters
with no further processing (except for header "folding" and
"unfolding" as described in section 2.2.3).
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from CommonField
#charset, #errors, #name, #value
Instance Method Summary collapse
-
#initialize(name, value, charset = nil) ⇒ UnstructuredField
constructor
:nodoc:.
-
#parse ⇒ Object
An unstructured field does not parse.
Methods inherited from CommonField
#decoded, #default, #element, #encoded, parse, #responsible_for?, singular?, #singular?, #to_s
Constructor Details
#initialize(name, value, charset = nil) ⇒ UnstructuredField
:nodoc:
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mail/fields/unstructured_field.rb', line 19 def initialize(name, value, charset = nil) if value.is_a?(Array) # Probably has arrived here from a failed parse of an AddressList Field value = value.join(', ') # Mark UTF-8 strings parsed from ASCII-8BIT elsif value.respond_to?(:force_encoding) && value.encoding == Encoding::ASCII_8BIT utf8 = value.dup.force_encoding(Encoding::UTF_8) value = utf8 if utf8.valid_encoding? end charset ||= if value.respond_to?(:encoding) value.encoding end super name, value.to_s, charset end |
Instance Method Details
#parse ⇒ Object
An unstructured field does not parse
39 40 41 |
# File 'lib/mail/fields/unstructured_field.rb', line 39 def parse self end |