Class: String

Inherits:
Object show all
Defined in:
lib/sh_util.rb

Instance Method Summary collapse

Instance Method Details

#to_md5Object



26
27
28
# File 'lib/sh_util.rb', line 26

def to_md5
  return (Digest::MD5.new << self).to_s
end

#to_uObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sh_util.rb', line 30

def to_u
  begin
    raise "Binary data!" if is_binary_data?
    utf8 = isutf8
    if utf8
      utf8 = utf8.to_s
    else
      utf8 = unpack('C*').pack('U*')
    end
    return utf8
  rescue Exception
    return nil
  end
end