Class: Mail::Jenc::PercentEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/mail/jenc/percent_encoder.rb

Class Method Summary collapse

Class Method Details

.encode(str) ⇒ Object



7
8
9
# File 'lib/mail/jenc/percent_encoder.rb', line 7

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

.encode_to_array(str) ⇒ Object



11
12
13
# File 'lib/mail/jenc/percent_encoder.rb', line 11

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