Class: TMail::Decoder
- Inherits:
-
Object
show all
- Includes:
- TextUtils
- Defined in:
- lib/action_mailer/vendor/tmail/encode.rb
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_phrase, #quote_token, #time2str, #timezone_string_to_unixtime, #to_kcode, #token_safe?
Constructor Details
#initialize(dest, encoding = nil, eol = "\n") ⇒ Decoder
Returns a new instance of Decoder.
95
96
97
98
99
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 95
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
89
90
91
92
93
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 89
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
117
118
119
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 117
def header_body( str )
@f << decode(str)
end
|
109
110
111
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 109
def ( str )
@f << decode(str)
end
|
113
114
115
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 113
def ( nm )
@f << nm << ': '
end
|
#kv_pair(k, v) ⇒ Object
143
144
145
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 143
def kv_pair( k, v )
@f << k << '=' << v
end
|
#lwsp(str) ⇒ Object
127
128
129
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 127
def lwsp( str )
@f << str
end
|
131
132
133
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 131
def meta( str )
@f << str
end
|
#phrase(str) ⇒ Object
139
140
141
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 139
def phrase( str )
@f << quote_phrase(decode(str))
end
|
#puts(str = nil) ⇒ Object
147
148
149
150
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 147
def puts( str = nil )
@f << str if str
@f << @eol
end
|
#space ⇒ Object
Also known as:
spc
121
122
123
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 121
def space
@f << ' '
end
|
#terminate ⇒ Object
106
107
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 106
def terminate
end
|
#text(str) ⇒ Object
135
136
137
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 135
def text( str )
@f << decode(str)
end
|
#write(str) ⇒ Object
152
153
154
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 152
def write( str )
@f << str
end
|