Class: Mail::Encodings::Base64
- Inherits:
-
SevenBit
- Object
- TransferEncoding
- Identity
- Binary
- EightBit
- SevenBit
- Mail::Encodings::Base64
- Defined in:
- lib/mail/encodings/base64.rb
Overview
Base64 encoding handles binary content at the cost of 4 output bytes per input byte.
Constant Summary collapse
- NAME =
'base64'
- PRIORITY =
3
Class Method Summary collapse
- .can_encode?(enc) ⇒ Boolean
-
.compatible_input?(str) ⇒ Boolean
Ruby Base64 inserts newlines automatically, so it doesn’t exceed SMTP line length limits.
-
.cost(str) ⇒ Object
3 bytes in -> 4 bytes out.
- .decode(str) ⇒ Object
- .encode(str) ⇒ Object
Methods inherited from TransferEncoding
can_transport?, lowest_cost, negotiate, renegotiate, to_s
Class Method Details
.can_encode?(enc) ⇒ Boolean
14 15 16 |
# File 'lib/mail/encodings/base64.rb', line 14 def self.can_encode?(enc) true end |
.compatible_input?(str) ⇒ Boolean
Ruby Base64 inserts newlines automatically, so it doesn’t exceed SMTP line length limits.
33 34 35 |
# File 'lib/mail/encodings/base64.rb', line 33 def self.compatible_input?(str) true end |
.cost(str) ⇒ Object
3 bytes in -> 4 bytes out
27 28 29 |
# File 'lib/mail/encodings/base64.rb', line 27 def self.cost(str) 4.0 / 3 end |
.decode(str) ⇒ Object
18 19 20 |
# File 'lib/mail/encodings/base64.rb', line 18 def self.decode(str) Utilities.decode_base64(str) end |
.encode(str) ⇒ Object
22 23 24 |
# File 'lib/mail/encodings/base64.rb', line 22 def self.encode(str) ::Mail::Utilities.binary_unsafe_to_crlf(Utilities.encode_base64(str)) end |