Module: Binascii::Uu

Included in:
Binascii
Defined in:
lib/binascii/uu.rb

Instance Method Summary collapse

Instance Method Details

#a2b_uu(str) ⇒ Object



14
15
16
17
18
# File 'lib/binascii/uu.rb', line 14

def a2b_uu(str)
  str.force_encoding('ASCII-8BIT')
  len = (str.getbyte(0) - 32) & 077
  str.unpack('u').first.rjust(len, "\0")
end

#b2a_uu(data, backtick: false) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/binascii/uu.rb', line 5

def b2a_uu(data, backtick: false)
  if data.bytesize == 0
    backtick ? "`\n" : " \n"
  else
    result = [data].pack('u')
    backtick ? result : result.gsub!('`', ' ')
  end
end