Class: String
- Inherits:
-
Object
show all
- Includes:
- WithoutAccents
- Defined in:
- lib/core-extensions/string_ext.rb,
lib/core-extensions/uids.rb,
lib/core-extensions/string_ext.rb,
lib/core-extensions/string_ext.rb,
lib/core-extensions/string_ext.rb,
lib/core-extensions/string_ext.rb
Overview
– decode HTML entities —————————————————–
Defined Under Namespace
Modules: HtmlDecoder
Constant Summary
WithoutAccents::ACCENTS_MAPPING, WithoutAccents::ACCENTS_MAPPING_REGEXPS
Instance Method Summary
collapse
#without_accents
Instance Method Details
4
5
6
|
# File 'lib/core-extensions/uids.rb', line 4
def crc32
Zlib.crc32(self)
end
|
#ends_with?(other) ⇒ Boolean
56
57
58
|
# File 'lib/core-extensions/string_ext.rb', line 56
def ends_with?(other)
length >= other.length && self[length - other.length .. -1] == other
end
|
8
9
10
|
# File 'lib/core-extensions/uids.rb', line 8
def md5
Digest::MD5.hexdigest(self)
end
|
41
42
43
44
45
46
47
48
|
# File 'lib/core-extensions/string_ext.rb', line 41
def sortkey
self.without_accents. downcase.
gsub(/^\s*(der|die|das|the|a|ein)\b\s*/, ""). gsub(/[0-9]+/) { |s| "%03d" % s.to_i }. gsub(/[^a-z0-9]/, "") end
|
#starts_with?(other) ⇒ Boolean
52
53
54
|
# File 'lib/core-extensions/string_ext.rb', line 52
def starts_with?(other)
length >= other.length && self[0, other.length] == other
end
|
21
22
23
24
25
26
27
28
29
|
# File 'lib/core-extensions/string_ext.rb', line 21
def to_utf8
encoding = 'ISO-8859-1'
Iconv.conv('utf-8', encoding, self)
end
|
13
14
15
|
# File 'lib/core-extensions/uids.rb', line 13
def uid64
md5.unpack("LL").inject { |a,b| (a << 31) + b }
end
|
12
13
14
|
# File 'lib/core-extensions/string_ext.rb', line 12
def unhtml
HtmlDecoder.instance.decode self
end
|