lib/jisx0208/processor.rb in jisx0208-0.2.0 vs lib/jisx0208/processor.rb in jisx0208-0.3.0

- old
+ new

@@ -15,10 +15,11 @@ end # see http://ash.jp/code/unitbl21.htm @first_level_ranges = collect_unicode_set(mappings, 0x3021, 0x4F53) @second_level_ranges = collect_unicode_set(mappings, 0x5021, 0x7426) + @others_ranges = collect_unicode_set(mappings, 0x2120, 0x2840) end def contains_first_level_kanji?(string) string.each_char.any? { |char| @first_level_ranges.include?(char.ord) } end @@ -29,19 +30,30 @@ def contains_jisx0208_kanji?(string) contains_first_level_kanji?(string) || contains_seconde_level_kanji?(string) end + def contains_jisx0208?(string) + contains_jisx0208_kanji?(string) || string.each_char.any? do |char| + @others_ranges.include?(char.ord) + end + end + def only_first_level_kanji?(string) string.each_char.all? { |char| @first_level_ranges.include?(char.ord) } end def only_second_level_kanji?(string) string.each_char.all? { |char| @second_level_ranges.include?(char.ord) } end def only_jisx0208_kanji?(string) jisx0208 = @first_level_ranges + @second_level_ranges + string.each_char.all? { |char| jisx0208.include?(char.ord) } + end + + def only_jisx0208?(string) + jisx0208 = @first_level_ranges + @second_level_ranges + @others_ranges string.each_char.all? { |char| jisx0208.include?(char.ord) } end private