Class: Mail::UnstructuredField

Inherits:
Object
  • Object
show all
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).

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 Attribute Summary collapse

Instance Method Summary collapse

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.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mail/fields/unstructured_field.rb', line 25

def initialize(name, value, charset = nil)
  @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 Attribute Details

#charsetObject

Returns the value of attribute charset.



22
23
24
# File 'lib/mail/fields/unstructured_field.rb', line 22

def charset
  @charset
end

#errorsObject (readonly)

Returns the value of attribute errors.



23
24
25
# File 'lib/mail/fields/unstructured_field.rb', line 23

def errors
  @errors
end

Instance Method Details

#decodedObject



45
46
47
# File 'lib/mail/fields/unstructured_field.rb', line 45

def decoded
  do_decode
end

#defaultObject



49
50
51
# File 'lib/mail/fields/unstructured_field.rb', line 49

def default
  decoded
end

#encodedObject



41
42
43
# File 'lib/mail/fields/unstructured_field.rb', line 41

def encoded
  do_encode
end

#parseObject

An unstructured field does not parse



53
54
55
# File 'lib/mail/fields/unstructured_field.rb', line 53

def parse # An unstructured field does not parse
  self
end