From 3a2f81cf9a9324957f06997447783a3c7a9177e9 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 20 Oct 2014 05:00:46 +0000 Subject: unicode_normalize/normalize.rb: remove unnecessary module names * lib/unicode_normalize/normalize.rb (UnicodeNormalize): use self instead of module name and remove module name if unnecessary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/unicode_normalize/normalize.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/unicode_normalize') diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb index 3075a56b50..22768f4c01 100644 --- a/lib/unicode_normalize/normalize.rb +++ b/lib/unicode_normalize/normalize.rb @@ -15,15 +15,15 @@ module UnicodeNormalize REGEXP_K = Regexp.compile(REGEXP_K_STRING, Regexp::EXTENDED) NF_HASH_D = Hash.new do |hash, key| hash.delete hash.first[0] if hash.length>MAX_HASH_LENGTH # prevent DoS attack - hash[key] = UnicodeNormalize.nfd_one(key) + hash[key] = nfd_one(key) end NF_HASH_C = Hash.new do |hash, key| hash.delete hash.first[0] if hash.length>MAX_HASH_LENGTH # prevent DoS attack - hash[key] = UnicodeNormalize.nfc_one(key) + hash[key] = nfc_one(key) end NF_HASH_K = Hash.new do |hash, key| hash.delete hash.first[0] if hash.length>MAX_HASH_LENGTH # prevent DoS attack - hash[key] = UnicodeNormalize.nfkd_one(key) + hash[key] = nfkd_one(key) end ## Constants For Hangul @@ -42,7 +42,7 @@ module UnicodeNormalize Encoding::GB18030, Encoding::UCS_2BE, Encoding::UCS_4BE] ## Hangul Algorithm - def UnicodeNormalize.hangul_decomp_one(target) + def self.hangul_decomp_one(target) sIndex = target.ord - SBASE return target if sIndex < 0 || sIndex >= SCOUNT l = LBASE + sIndex / NCOUNT @@ -51,7 +51,7 @@ module UnicodeNormalize (t==TBASE ? [l, v] : [l, v, t]).pack('U*') + target[1..-1] end - def UnicodeNormalize.hangul_comp_one(string) + def self.hangul_comp_one(string) length = string.length if length>1 and 0 <= (lead =string[0].ord-LBASE) and lead < LCOUNT and 0 <= (vowel=string[1].ord-VBASE) and vowel < VCOUNT @@ -67,7 +67,7 @@ module UnicodeNormalize end ## Canonical Ordering - def UnicodeNormalize.canonical_ordering_one(string) + def self.canonical_ordering_one(string) sorting = string.each_char.collect { |c| [c, CLASS_TABLE[c]] } (sorting.length-2).downto(0) do |i| # bubble sort (0..i).each do |j| @@ -81,7 +81,7 @@ module UnicodeNormalize end ## Normalization Forms for Patterns (not whole Strings) - def UnicodeNormalize.nfd_one(string) + def self.nfd_one(string) string = string.dup (0...string.length).each do |position| if decomposition = DECOMPOSITION_TABLE[string[position]] @@ -91,7 +91,7 @@ module UnicodeNormalize canonical_ordering_one(hangul_decomp_one(string)) end - def UnicodeNormalize.nfkd_one(string) + def self.nfkd_one(string) string = string.dup position = 0 while position < string.length @@ -104,7 +104,7 @@ module UnicodeNormalize string end - def UnicodeNormalize.nfc_one (string) + def self.nfc_one (string) nfd_string = nfd_one string start = nfd_string[0] last_class = CLASS_TABLE[start]-1 @@ -121,7 +121,7 @@ module UnicodeNormalize hangul_comp_one(start+accents) end - def UnicodeNormalize.normalize(string, form = :nfc) + def self.normalize(string, form = :nfc) encoding = string.encoding if encoding == Encoding::UTF_8 case form @@ -143,7 +143,7 @@ module UnicodeNormalize end end - def UnicodeNormalize.normalized?(string, form = :nfc) + def self.normalized?(string, form = :nfc) encoding = string.encoding if encoding == Encoding::UTF_8 case form -- cgit v1.2.3