Class: Mail::Body
- Inherits:
-
Object
- Object
- Mail::Body
- Defined in:
- lib/jpmobile/mail.rb
Instance Attribute Summary collapse
-
#content_type_with_jpmobile ⇒ Object
Returns the value of attribute content_type_with_jpmobile.
-
#mobile ⇒ Object
Returns the value of attribute mobile.
Instance Method Summary collapse
- #crlf_boundary_with_jpmobile ⇒ Object (also: #crlf_boundary)
- #decode_transfer_encoding ⇒ Object
- #decoded_with_jpmobile ⇒ Object (also: #decoded)
-
#encoded_with_jpmobile(transfer_encoding = '8bit') ⇒ Object
(also: #encoded)
convert encoding.
- #end_boundary_with_jpmobile ⇒ Object (also: #end_boundary)
- #epilogue_with_jpmobile ⇒ Object (also: #epilogue)
- #preamble_with_jpmobile ⇒ Object (also: #preamble)
- #raw_source_with_jpmobile ⇒ Object (also: #raw_source)
-
#set_charset_with_jpmobile ⇒ Object
(also: #set_charset)
fix charset.
- #split!(boundary) ⇒ Object
Instance Attribute Details
#content_type_with_jpmobile ⇒ Object
Returns the value of attribute content_type_with_jpmobile.
300 301 302 |
# File 'lib/jpmobile/mail.rb', line 300 def content_type_with_jpmobile @content_type_with_jpmobile end |
#mobile ⇒ Object
Returns the value of attribute mobile.
299 300 301 |
# File 'lib/jpmobile/mail.rb', line 299 def mobile @mobile end |
Instance Method Details
#crlf_boundary_with_jpmobile ⇒ Object Also known as: crlf_boundary
374 375 376 377 378 379 380 |
# File 'lib/jpmobile/mail.rb', line 374 def crlf_boundary_with_jpmobile if @mobile Jpmobile::Util.encode(crlf_boundary_without_jpmobile, @mobile.mail_charset(@charset)) else crlf_boundary_without_jpmobile end end |
#decode_transfer_encoding ⇒ Object
352 353 354 355 356 |
# File 'lib/jpmobile/mail.rb', line 352 def decode_transfer_encoding _raw_source = Jpmobile::Util.decode(@raw_source, self.encoding, @charset) @raw_source = @mobile.decode_transfer_encoding(_raw_source, @charset) self.encoding = 'text' end |
#decoded_with_jpmobile ⇒ Object Also known as: decoded
327 328 329 |
# File 'lib/jpmobile/mail.rb', line 327 def decoded_with_jpmobile decoded_without_jpmobile end |
#encoded_with_jpmobile(transfer_encoding = '8bit') ⇒ Object Also known as: encoded
convert encoding
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/jpmobile/mail.rb', line 307 def encoded_with_jpmobile(transfer_encoding = '8bit') if @mobile && !multipart? case transfer_encoding when /base64/ _raw_source = if transfer_encoding == encoding @raw_source.dup else negotiate_best_encoding(transfer_encoding).encode(@raw_source) end Jpmobile::Util.set_encoding(_raw_source, @mobile.mail_charset(@charset)) when /quoted-printable/ Jpmobile::Util.set_encoding([@mobile.to_mail_body(@raw_source)].pack('M').gsub("\n", "\r\n"), @mobile.mail_charset(@charset)) else @mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, nil, Jpmobile::Util::UTF8)) end else encoded_without_jpmobile(transfer_encoding) end end |
#end_boundary_with_jpmobile ⇒ Object Also known as: end_boundary
382 383 384 385 386 387 388 |
# File 'lib/jpmobile/mail.rb', line 382 def end_boundary_with_jpmobile if @mobile Jpmobile::Util.encode(end_boundary_without_jpmobile, @mobile.mail_charset(@charset)) else end_boundary_without_jpmobile end end |
#epilogue_with_jpmobile ⇒ Object Also known as: epilogue
366 367 368 369 370 371 372 |
# File 'lib/jpmobile/mail.rb', line 366 def epilogue_with_jpmobile if @mobile Jpmobile::Util.encode(@epilogue, @mobile.mail_charset(@charset)) else epilogue_without_jpmobile end end |
#preamble_with_jpmobile ⇒ Object Also known as: preamble
358 359 360 361 362 363 364 |
# File 'lib/jpmobile/mail.rb', line 358 def preamble_with_jpmobile if @mobile Jpmobile::Util.encode(@preamble, @mobile.mail_charset(@charset)) else preamble_without_jpmobile end end |
#raw_source_with_jpmobile ⇒ Object Also known as: raw_source
302 303 304 |
# File 'lib/jpmobile/mail.rb', line 302 def raw_source_with_jpmobile ::Mail::Utilities.to_crlf(raw_source_without_jpmobile) end |
#set_charset_with_jpmobile ⇒ Object Also known as: set_charset
fix charset
332 333 334 |
# File 'lib/jpmobile/mail.rb', line 332 def set_charset_with_jpmobile @charset ||= ascii_only? ? 'US-ASCII' : nil end |
#split!(boundary) ⇒ Object
414 415 416 417 418 419 420 421 422 423 |
# File 'lib/jpmobile/mail.rb', line 414 def split!(boundary) self.boundary = boundary parts = raw_source.split(/(?:\A|\r\n)--#{Regexp.escape(boundary)}(?=(?:--)?\s*$)/) # Make the preamble equal to the preamble (if any) self.preamble = parts[0].to_s.strip # Make the epilogue equal to the epilogue (if any) self.epilogue = parts[-1].to_s.sub('--', '').strip parts[1...-1].to_a.each {|part| @parts << Mail::Part.new(body_raw: part, mobile: @mobile) } self end |