Class: TMail::HeaderField

Inherits:
Object show all
Includes:
StrategyInterface, TextUtils
Defined in:
lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb,
lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb

Overview

redefine

Direct Known Subclasses

StructuredHeader, UnstructuredHeader

Constant Summary collapse

FNAME_TO_CLASS =
{
  'date'                      => DateTimeHeader,
  'resent-date'               => DateTimeHeader,
  'to'                        => AddressHeader,
  'cc'                        => AddressHeader,
  'bcc'                       => AddressHeader,
  'from'                      => AddressHeader,
  'reply-to'                  => AddressHeader,
  'resent-to'                 => AddressHeader,
  'resent-cc'                 => AddressHeader,
  'resent-bcc'                => AddressHeader,
  'resent-from'               => AddressHeader,
  'resent-reply-to'           => AddressHeader,
  'sender'                    => SingleAddressHeader,
  'resent-sender'             => SingleAddressHeader,
  'return-path'               => ReturnPathHeader,
  'message-id'                => MessageIdHeader,
  'resent-message-id'         => MessageIdHeader,
  'in-reply-to'               => ReferencesHeader,
  'received'                  => ReceivedHeader,
  'references'                => ReferencesHeader,
  'keywords'                  => KeywordsHeader,
  'encrypted'                 => EncryptedHeader,
  'mime-version'              => MimeVersionHeader,
  'content-type'              => ContentTypeHeader,
  'content-transfer-encoding' => ContentTransferEncodingHeader,
  'content-disposition'       => ContentDispositionHeader,
  'content-id'                => MessageIdHeader,
  'subject'                   => UnstructuredHeader,
  'comments'                  => UnstructuredHeader,
  'content-description'       => UnstructuredHeader
}

Constants included from TextUtils

TextUtils::ATOM_UNSAFE, TextUtils::CONTROL_CHAR, TextUtils::MESSAGE_ID, TextUtils::MIME_ENCODED, TextUtils::MONTH, TextUtils::NKF_FLAGS, TextUtils::PHRASE_UNSAFE, TextUtils::RFC2231_ENCODED, TextUtils::TOKEN_UNSAFE, TextUtils::WDAY, TextUtils::ZONESTR_TABLE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StrategyInterface

#accept_strategy, create_dest, #decoded, #encoded

Methods included from TextUtils

#atom_safe?, #decode_RFC2231, #decode_params, #join_domain, #message_id?, #mime_encoded?, #quote_atom, #quote_boundary, #quote_phrase, #quote_token, #time2str, #timezone_string_to_unixtime, #to_kcode, #token_safe?, #unquote

Constructor Details

#initialize(body, conf, intern = false) ⇒ HeaderField

class << self



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 78

def initialize( body, conf, intern = false )
  @body = body
  @config = conf

  @illegal = false
  @parsed = false
  
  if intern
    @parsed = true
    parse_init
  end
end

Class Method Details

.internal_new(name, conf) ⇒ Object



72
73
74
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 72

def internal_new( name, conf )
  FNAME_TO_CLASS[name].newobj('', conf, true)
end

.new(name, body, conf = DEFAULT_CONFIG) ⇒ Object



52
53
54
55
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 52

def new( name, body, conf = DEFAULT_CONFIG )
  klass = FNAME_TO_CLASS[name.downcase] || UnstructuredHeader
  klass.newobj body, conf
end

.new_from_port(port, name, conf = DEFAULT_CONFIG) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 57

def new_from_port( port, name, conf = DEFAULT_CONFIG )
  re = Regep.new('\A(' + Regexp.quote(name) + '):', 'i')
  str = nil
  port.ropen {|f|
      f.each do |line|
        if m = re.match(line)            then str = m.post_match.strip
        elsif str and /\A[\t ]/ === line then str << ' ' << line.strip
        elsif /\A-*\s*\z/ === line       then break
        elsif str                        then break
        end
      end
  }
  new(name, str, Config.to_config(conf))
end

.newobjObject



50
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 50

alias newobj new

Instance Method Details

#accept(strategy) ⇒ Object



138
139
140
141
142
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 138

def accept( strategy )
  ensure_parsed
  do_accept strategy
  strategy.terminate
end

#bodyObject



123
124
125
126
127
128
129
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 123

def body
  ensure_parsed
  v = Decoder.new(s = '')
  do_accept v
  v.terminate
  s
end

#body=(str) ⇒ Object



131
132
133
134
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 131

def body=( str )
  @body = str
  clear_parse_status
end

#empty?Boolean

Returns:

  • (Boolean)


99
100
101
102
103
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 99

def empty?
  ensure_parsed
  return true if @illegal
  isempty?
end

#illegal?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 95

def illegal?
  @illegal
end

#inspectObject



91
92
93
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb', line 91

def inspect
  "#<#{self.class} #{@body.inspect}>"
end