Class: Mail::Encodings::Base64

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

Constant Summary collapse

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)


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

def self.can_encode?(enc)
  true
end

.cost(str) ⇒ Object

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



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

def self.cost(str)
  4.0/3
end

.decode(str) ⇒ Object

Decode the string from Base64



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

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

.encode(str) ⇒ Object

Encode the string to Base64



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

def self.encode(str)
  RubyVer.encode_base64( str ).to_crlf
end