Class: TMail::Decoder
Overview
Constant Summary
collapse
- ENCODED_WORDS =
/#{encoded}(?:\s+#{encoded})*/i
- OUTPUT_ENCODING =
{
'EUC' => 'e',
'SJIS' => 's',
}
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 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(dest, encoding = nil, eol = "\n") ⇒ Decoder
Returns a new instance of Decoder.
99
100
101
102
103
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 99
def initialize( dest, encoding = nil, eol = "\n" )
@f = StrategyInterface.create_dest(dest)
@encoding = (/\A[ejs]/ === encoding) ? encoding[0,1] : nil
@eol = eol
end
|
Class Method Details
.decode(str, encoding = nil) ⇒ Object
93
94
95
96
97
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 93
def self.decode( str, encoding = nil )
encoding ||= (OUTPUT_ENCODING[$KCODE] || 'j')
opt = '-m' + encoding
str.gsub(ENCODED_WORDS) {|s| NKF.nkf(opt, s) }
end
|
Instance Method Details
#header_body(str) ⇒ Object
121
122
123
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 121
def header_body( str )
@f << decode(str)
end
|
113
114
115
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 113
def ( str )
@f << decode(str)
end
|
117
118
119
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 117
def ( nm )
@f << nm << ': '
end
|
#kv_pair(k, v) ⇒ Object
147
148
149
150
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 147
def kv_pair( k, v )
v = dquote(v) unless token_safe?(v)
@f << k << '=' << v
end
|
#lwsp(str) ⇒ Object
131
132
133
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 131
def lwsp( str )
@f << str
end
|
135
136
137
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 135
def meta( str )
@f << str
end
|
#phrase(str) ⇒ Object
143
144
145
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 143
def phrase( str )
@f << quote_phrase(decode(str))
end
|
#puts(str = nil) ⇒ Object
152
153
154
155
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 152
def puts( str = nil )
@f << str if str
@f << @eol
end
|
#space ⇒ Object
Also known as:
spc
125
126
127
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 125
def space
@f << ' '
end
|
#terminate ⇒ Object
110
111
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 110
def terminate
end
|
#text(str) ⇒ Object
139
140
141
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 139
def text( str )
@f << decode(str)
end
|
#write(str) ⇒ Object
157
158
159
|
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb', line 157
def write( str )
@f << str
end
|