Class: Mail::UnstructuredField
- Includes:
- CommonField, Utilities
- 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
CommentsField, ContentDescriptionField, OptionalField, SubjectField
Constant Summary
Constants included from Patterns
Patterns::ATOM_UNSAFE, Patterns::CONTROL_CHAR, Patterns::CRLF, Patterns::FIELD_BODY, Patterns::FIELD_LINE, Patterns::FIELD_NAME, Patterns::FWS, Patterns::HEADER_LINE, Patterns::PHRASE_UNSAFE, Patterns::QP_SAFE, Patterns::QP_UNSAFE, Patterns::TEXT, Patterns::TOKEN_UNSAFE, Patterns::WSP
Instance Method Summary collapse
- #charset ⇒ Object
- #charset=(val) ⇒ Object
- #decoded ⇒ Object
- #default ⇒ Object
- #encoded ⇒ Object
- #errors ⇒ Object
-
#initialize(name, value, charset = nil) ⇒ UnstructuredField
constructor
A new instance of UnstructuredField.
-
#parse ⇒ Object
An unstructured field does not parse.
Methods included from Utilities
#atom_safe?, #bracket, #capitalize_field, #constantize, #dasherize, #dquote, #escape_paren, #map_lines, #map_with_index, #match_to_s, #paren, #quote_atom, #quote_phrase, #quote_token, #token_safe?, #unbracket, #underscoreize, #unparen, #unquote, #uri_escape, #uri_parser, #uri_unescape
Methods included from CommonField
#field_length, #name, #name=, #responsible_for?, #to_s, #value, #value=
Constructor Details
#initialize(name, value, charset = nil) ⇒ UnstructuredField
Returns a new instance of UnstructuredField.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mail/fields/unstructured_field.rb', line 22 def initialize(name, value, charset = nil) self.charset = charset @errors = [] if charset self.charset = charset else if value.to_s.respond_to?(:encoding) self.charset = value.to_s.encoding else self.charset = $KCODE end end self.name = name self.value = value self end |
Instance Method Details
#charset ⇒ Object
39 40 41 |
# File 'lib/mail/fields/unstructured_field.rb', line 39 def charset @charset end |
#charset=(val) ⇒ Object
43 44 45 |
# File 'lib/mail/fields/unstructured_field.rb', line 43 def charset=(val) @charset = val end |
#decoded ⇒ Object
55 56 57 |
# File 'lib/mail/fields/unstructured_field.rb', line 55 def decoded do_decode end |
#default ⇒ Object
59 60 61 |
# File 'lib/mail/fields/unstructured_field.rb', line 59 def default decoded end |
#encoded ⇒ Object
51 52 53 |
# File 'lib/mail/fields/unstructured_field.rb', line 51 def encoded do_encode(self.name) end |
#errors ⇒ Object
47 48 49 |
# File 'lib/mail/fields/unstructured_field.rb', line 47 def errors @errors end |
#parse ⇒ Object
An unstructured field does not parse
63 64 65 |
# File 'lib/mail/fields/unstructured_field.rb', line 63 def parse # An unstructured field does not parse self end |