class String
– decode HTML entities —————————————————–
Public Instance Methods
crc32()
click to toggle source
# File lib/core-extensions/uids.rb, line 4 def crc32 Zlib.crc32(self) end
ends_with?(other)
click to toggle source
# File lib/core-extensions/string_ext.rb, line 56 def ends_with?(other) length >= other.length && self[length - other.length .. -1] == other end
md5()
click to toggle source
# File lib/core-extensions/uids.rb, line 8 def md5 Digest::MD5.hexdigest(self) end
sortkey()
click to toggle source
# File lib/core-extensions/string_ext.rb, line 41 def sortkey # Convert the key into an sortable ascii string self.without_accents. # remove accents downcase. gsub(/^\s*(der|die|das|the|a|ein)\b\s*/, ""). # remove leading stop words gsub(/[0-9]+/) { |s| "%03d" % s.to_i }. # fill in leading zeroes gsub(/[^a-z0-9]/, "") # keep only letters and digits end
starts_with?(other)
click to toggle source
# File lib/core-extensions/string_ext.rb, line 52 def starts_with?(other) length >= other.length && self[0, other.length] == other end
to_utf8()
click to toggle source
# File lib/core-extensions/string_ext.rb, line 21 def to_utf8 # require "charguess" # encoding = CharGuess.guess(self) # puts "encoding: #{encoding.inspect}" # return self if !encoding || encoding == "UTF-8" encoding = 'ISO-8859-1' Iconv.conv('utf-8', encoding, self) end
uid64()
click to toggle source
return a 64 bit uid
# File lib/core-extensions/uids.rb, line 13 def uid64 md5.unpack("LL").inject { |a,b| (a << 31) + b } end
unhtml()
click to toggle source
# File lib/core-extensions/string_ext.rb, line 12 def unhtml HtmlDecoder.instance.decode self end