Class: Mail::Encodings::Base64

Inherits:
SevenBit show all
Defined in:
lib/mail/encodings/base64.rb

Constant Summary

NAME =
'base64'
PRIORITY =
3

Class Method Summary collapse

Methods inherited from TransferEncoding

can_transport?, get_best_compatible, to_s, #to_s

Class Method Details

.can_encode?(enc) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/mail/encodings/base64.rb', line 12

def self.can_encode?(enc)
  true
end

.compatible_input?(str) ⇒ Boolean

Base64 inserts newlines automatically and cannot violate the SMTP spec.

Returns:

  • (Boolean)


32
33
34
# File 'lib/mail/encodings/base64.rb', line 32

def self.compatible_input?(str)
  true
end

.cost(str) ⇒ Object

Base64 has a fixed cost, 4 bytes out per 3 bytes in



27
28
29
# File 'lib/mail/encodings/base64.rb', line 27

def self.cost(str)
  4.0/3
end

.decode(str) ⇒ Object

Decode the string from Base64



17
18
19
# File 'lib/mail/encodings/base64.rb', line 17

def self.decode(str)
  RubyVer.decode_base64( str )
end

.encode(str) ⇒ Object

Encode the string to Base64



22
23
24
# File 'lib/mail/encodings/base64.rb', line 22

def self.encode(str)
  ::Mail::Utilities.to_crlf(RubyVer.encode_base64( str ))
end