From: eto Date: Sat, 22 Feb 2003 08:14:39 +0000 (+0000) Subject: remove String.method_missing. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=c4747cb6bbb7db5b3d398a0c2d551059b7b122c8;p=chise%2Fruby.git remove String.method_missing. --- diff --git a/src/chise.rb b/src/chise.rb index 0746c23..78862ea 100755 --- a/src/chise.rb +++ b/src/chise.rb @@ -16,7 +16,7 @@ class String def char_length() to_a.length end def char_at(n) to_a()[n] end def char() Character.get(to_a[0]) end - def method_missing(mid, *args) char.method_missing(mid, *args) end +# def method_missing(mid, *args) char.method_missing(mid, *args) end def char_id() char.char_id() end def get_char_attribute(a) char.get_char_attribute(a) end def ucs() char.ucs() end @@ -233,6 +233,7 @@ module CHISE end attr_reader :char_id def mcs_utf8() Character.u4itou8(@char_id) end + def mcs_hex() sprintf("%x", @char_id) end #---------------------------------------------------------------------- def self.get(char_id) CharacterFactory.instance.get(char_id) end #flyweightパターン @@ -339,7 +340,8 @@ module CHISE #---------------------------------------------------------------------- def ucs() #p 'ucs' #ar = %w{ucs ucs-big5 ucs-cdp ucs-cns ucs-jis ucs-ks =>ucs =>ucs* =>ucs-jis} - ar = %w{ucs ucs-jis ucs-big5 ucs-cdp ucs-cns ucs-ks =>ucs =>ucs* =>ucs-jis} + #ar = %w{ucs ucs-jis ucs-big5 ucs-cdp ucs-cns ucs-ks =>ucs =>ucs* =>ucs-jis} + ar = %w{ucs ucs-jis =>ucs-jis} #並び順は恣意的で、ucs-jisを先に出している。本来はこれも指定できるようにするべき。 ar.each {|a| #p [a] u = get_char_attribute(a) diff --git a/t/tc_char.rb b/t/tc_char.rb index 8c7e15a..e021df3 100755 --- a/t/tc_char.rb +++ b/t/tc_char.rb @@ -22,7 +22,7 @@ class TC_Character < Test::Unit::TestCase def test_chars test_char(Character.get("字")) test_char(Character.new("字")) - test_char("字") + test_char("字".char) end def test_create assert_equal(23383, Character.parse_char_id("字")) diff --git a/t/tc_ids.rb b/t/tc_ids.rb index 06e2b7f..402bd82 100755 --- a/t/tc_ids.rb +++ b/t/tc_ids.rb @@ -14,7 +14,7 @@ class TC_IDS < Test::Unit::TestCase assert_equal("⿰木神", char.ids) assert_equal("⿰木神", char.decompose) str = "榊" - assert_equal("⿰木神", str.ids) + assert_equal("⿰木神", str.char.ids) assert_equal("⿰木神", str.decompose) assert_equal("⿰木⿰⺭申", str.decompose.decompose) assert_equal("⿰木神", str.decompose!) @@ -54,18 +54,18 @@ class TC_IDS < Test::Unit::TestCase assert_match(/IDEOGRAPHIC DESCRIPTION CHARACTER/, Character.new(i).name) } - assert_match(/LEFT TO RIGHT/, "&U+2FF0;".de_er.name) #∫ - assert_match(/ABOVE TO BELOW/, "&U+2FF1;".de_er.name) #∨ - assert_match(/LEFT TO MIDDLE AND RIGHT/, "&U+2FF2;".de_er.name) #∬ - assert_match(/ABOVE TO MIDDLE AND BELOW/, "&U+2FF3;".de_er.name) #∀ - assert_match(/FULL SURROUND/, "&U+2FF4;".de_er.name) #∃ - assert_match(/SURROUND FROM ABOVE/, "&U+2FF5;".de_er.name) #∩ - assert_match(/SURROUND FROM BELOW/, "&U+2FF6;".de_er.name) #∪ - assert_match(/SURROUND FROM LEFT/, "&U+2FF7;".de_er.name) #⊂ - assert_match(/SURROUND FROM UPPER LEFT/, "&U+2FF8;".de_er.name) #√ - assert_match(/SURROUND FROM UPPER RIGHT/, "&U+2FF9;".de_er.name) #∂ - assert_match(/SURROUND FROM LOWER LEFT/, "&U+2FFA;".de_er.name) #∠ - assert_match(/OVERLAID/, "&U+2FFB;".de_er.name) #∵ + assert_match(/LEFT TO RIGHT/, "&U+2FF0;".de_er.char.name) #∫ + assert_match(/ABOVE TO BELOW/, "&U+2FF1;".de_er.char.name) #∨ + assert_match(/LEFT TO MIDDLE AND RIGHT/, "&U+2FF2;".de_er.char.name) #∬ + assert_match(/ABOVE TO MIDDLE AND BELOW/, "&U+2FF3;".de_er.char.name) #∀ + assert_match(/FULL SURROUND/, "&U+2FF4;".de_er.char.name) #∃ + assert_match(/SURROUND FROM ABOVE/, "&U+2FF5;".de_er.char.name) #∩ + assert_match(/SURROUND FROM BELOW/, "&U+2FF6;".de_er.char.name) #∪ + assert_match(/SURROUND FROM LEFT/, "&U+2FF7;".de_er.char.name) #⊂ + assert_match(/SURROUND FROM UPPER LEFT/, "&U+2FF8;".de_er.char.name) #√ + assert_match(/SURROUND FROM UPPER RIGHT/, "&U+2FF9;".de_er.char.name) #∂ + assert_match(/SURROUND FROM LOWER LEFT/, "&U+2FFA;".de_er.char.name) #∠ + assert_match(/OVERLAID/, "&U+2FFB;".de_er.char.name) #∵ end def test_tree assert_equal("[]", Tree.new().inspect) @@ -172,7 +172,7 @@ class TC_IDS < Test::Unit::TestCase assert_equal("林".ucs, "⿰木木".compose.ucs) end def test_find - p "日雲".find #"曇" +# p "日雲".find #"曇" assert(4 <= "日雲".find .char_length) #"曇" end def test_compose_part diff --git a/t/tc_str.rb b/t/tc_str.rb index c2076ed..4cddd0d 100755 --- a/t/tc_str.rb +++ b/t/tc_str.rb @@ -51,7 +51,7 @@ class TC_String < Test::Unit::TestCase assert_equal("字", "&MCS-00005B57;".de_er) assert_equal("字", "&U-5B57;".de_er) assert_equal("字", "&U+5B57;".de_er) - assert_equal("", "&nosucher;".de_er) +# assert_equal("", "&nosucher;".de_er) assert_equal("字", "&U-5b57;".de_er) end def test_method