class TwitterCldr::Shared::Casefolder
Constants
- CASEFOLDING_HASH
- CASEFOLDING_HASH_T
- CASEFOLDING_SOURCE_C
- CASEFOLDING_SOURCE_F
- CASEFOLDING_SOURCE_S
- CASEFOLDING_SOURCE_T
Public Class Methods
common_casefold(str)
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 221 def common_casefold(str) perform_casefold(str, CASEFOLDING_REGEX_C, false) end
full_casefold(str, t = false)
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 215 def full_casefold(str, t = false) perform_casefold(str, full_casefold_regex, t) end
Also aliased as: casefold
simple_casefold(str, t = false)
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 211 def simple_casefold(str, t = false) perform_casefold(str, simple_casefold_regex, t) end
Private Class Methods
full_casefold_regex()
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 242 def full_casefold_regex @full_casefold_regex ||= Regexp.new("#{CASEFOLDING_SOURCE_C}|#{CASEFOLDING_SOURCE_F}") end
perform_casefold(str, regex, t)
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 227 def perform_casefold(str, regex, t) regex = regex_with_t(regex) if t casefolding_hash = t ? CASEFOLDING_HASH_T : CASEFOLDING_HASH str.gsub(regex) do |s| s.unpack("U*").inject([]) do |ret, ss| ret + casefolding_hash[ss] end.pack("U*") end end
regex_with_t(regex)
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 246 def regex_with_t(regex) regex_with_t_cache[regex.source] ||= Regexp.new("#{regex.source}|#{CASEFOLDING_SOURCE_T}") end
regex_with_t_cache()
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 251 def regex_with_t_cache @regex_with_t_cache ||= {} end
simple_casefold_regex()
click to toggle source
# File lib/twitter_cldr/shared/casefolder.rb, line 238 def simple_casefold_regex @simple_casefold_regex ||= Regexp.new("#{CASEFOLDING_SOURCE_C}|#{CASEFOLDING_SOURCE_S}") end