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.
76
77
78
79
80
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 76
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
70
71
72
73
74
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 70
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
98
99
100
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 98
def header_body( str )
@f << decode(str)
end
|
90
91
92
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 90
def ( str )
@f << decode(str)
end
|
94
95
96
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 94
def ( nm )
@f << nm << ': '
end
|
#kv_pair(k, v) ⇒ Object
124
125
126
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 124
def kv_pair( k, v )
@f << k << '=' << v
end
|
#lwsp(str) ⇒ Object
108
109
110
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 108
def lwsp( str )
@f << str
end
|
112
113
114
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 112
def meta( str )
@f << str
end
|
#phrase(str) ⇒ Object
120
121
122
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 120
def phrase( str )
@f << quote_phrase(decode(str))
end
|
#puts(str = nil) ⇒ Object
128
129
130
131
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 128
def puts( str = nil )
@f << str if str
@f << @eol
end
|
#space ⇒ Object
Also known as:
spc
102
103
104
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 102
def space
@f << ' '
end
|
#terminate ⇒ Object
87
88
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 87
def terminate
end
|
#text(str) ⇒ Object
116
117
118
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 116
def text( str )
@f << decode(str)
end
|
#write(str) ⇒ Object
133
134
135
|
# File 'lib/action_mailer/vendor/tmail/encode.rb', line 133
def write( str )
@f << str
end
|