class Mail::UnstructuredField

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).

Public Instance Methods

charset() click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 38
def charset
  @charset
end
charset=(val) click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 42
def charset=(val)
  @charset = val
end
decoded() click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 54
def decoded
  do_decode
end
default() click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 58
def default
  decoded
end
encoded() click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 50
def encoded
  do_encode(self.name)
end
errors() click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 46
def errors
  @errors
end
parse() click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 62
def parse # An unstructured field does not parse
  self
end

Public Class Methods

new(name, value, charset = nil) click to toggle source
# File lib/mail/fields/unstructured_field.rb, line 21
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