Module: Mail::Jenc::PercentEncoder

Defined in:
lib/mail/jenc/encoder.rb

Class Method Summary collapse

Class Method Details

.encode(str) ⇒ Object



5
6
7
# File 'lib/mail/jenc/encoder.rb', line 5

def encode(str)
  encode_to_array(str).join
end

.encode_to_array(str) ⇒ Object



9
10
11
# File 'lib/mail/jenc/encoder.rb', line 9

def encode_to_array(str)
  str.unpack('H*').first.scan(/.{2}/).map { |hex| "%#{hex.upcase}" }
end