[前][次][番号順一覧][スレッド一覧]

ruby-changes:35963

From: nobu <ko1@a...>
Date: Mon, 20 Oct 2014 14:01:01 +0900 (JST)
Subject: [ruby-changes:35963] nobu:r48044 (trunk): unicode_normalize/normalize.rb: remove unnecessary module names

nobu	2014-10-20 14:00:46 +0900 (Mon, 20 Oct 2014)

  New Revision: 48044

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48044

  Log:
    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.

  Modified files:
    trunk/lib/unicode_normalize/normalize.rb
Index: lib/unicode_normalize/normalize.rb
===================================================================
--- lib/unicode_normalize/normalize.rb	(revision 48043)
+++ lib/unicode_normalize/normalize.rb	(revision 48044)
@@ -15,15 +15,15 @@ module UnicodeNormalize https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L15
   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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L42
                        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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L51
     (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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L67
   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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L81
   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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L91
     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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L104
     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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L121
     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 https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L143
     end
   end
 
-  def UnicodeNormalize.normalized?(string, form = :nfc)
+  def self.normalized?(string, form = :nfc)
     encoding = string.encoding
     if encoding == Encoding::UTF_8
       case form

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]