Class: String

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

Instance Method Summary collapse

Instance Method Details

#to_md5Object



54
55
56
# File 'lib/sh_util.rb', line 54

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

#to_uObject



58
59
60
61
62
63
64
65
# File 'lib/sh_util.rb', line 58

def to_u
  if is_binary_data?
  	return isutf8 ? self : nil
  else
    utf8 = isutf8
    return utf8 ? utf8.to_s : unpack('C*').pack('U*')
  end
end

#unescape_htmlObject



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/sh_util.rb', line 67

def unescape_html
  entities = {
    "&quot;" => "\"",
    "&apos;" => "'",
    "&amp;" => "&",
    "&lt;" => "<",
    "&gt;" => ">",
    "&nbsp;" => " "
  }

  return CGI.unescapeHTML(self.gsub(/&\w*;/) {|e| entities[e] || e})
end