Class: UnihanLang::ChineseProcessor
- Inherits:
-
Object
- Object
- UnihanLang::ChineseProcessor
- Defined in:
- lib/unihan_lang/chinese_processor.rb
Instance Attribute Summary collapse
-
#common ⇒ Object
readonly
Returns the value of attribute common.
-
#zh_cn ⇒ Object
readonly
Returns the value of attribute zh_cn.
-
#zh_tw ⇒ Object
readonly
Returns the value of attribute zh_tw.
Instance Method Summary collapse
- #chinese?(char) ⇒ Boolean
- #chinese_character?(char) ⇒ Boolean
-
#initialize ⇒ ChineseProcessor
constructor
A new instance of ChineseProcessor.
- #only_zh_cn?(char) ⇒ Boolean
- #only_zh_tw?(char) ⇒ Boolean
- #zh_cn?(char) ⇒ Boolean
- #zh_tw?(char) ⇒ Boolean
Constructor Details
#initialize ⇒ ChineseProcessor
Returns a new instance of ChineseProcessor.
7 8 9 10 11 12 |
# File 'lib/unihan_lang/chinese_processor.rb', line 7 def initialize @zh_tw = Set.new @zh_cn = Set.new @common = Set.new load_chinese_characters end |
Instance Attribute Details
#common ⇒ Object (readonly)
Returns the value of attribute common.
5 6 7 |
# File 'lib/unihan_lang/chinese_processor.rb', line 5 def common @common end |
#zh_cn ⇒ Object (readonly)
Returns the value of attribute zh_cn.
5 6 7 |
# File 'lib/unihan_lang/chinese_processor.rb', line 5 def zh_cn @zh_cn end |
#zh_tw ⇒ Object (readonly)
Returns the value of attribute zh_tw.
5 6 7 |
# File 'lib/unihan_lang/chinese_processor.rb', line 5 def zh_tw @zh_tw end |
Instance Method Details
#chinese?(char) ⇒ Boolean
30 31 32 |
# File 'lib/unihan_lang/chinese_processor.rb', line 30 def chinese?(char) zh_tw?(char) || zh_cn?(char) || cjk?(char) end |
#chinese_character?(char) ⇒ Boolean
34 35 36 |
# File 'lib/unihan_lang/chinese_processor.rb', line 34 def chinese_character?(char) chinese?(char) end |
#only_zh_cn?(char) ⇒ Boolean
26 27 28 |
# File 'lib/unihan_lang/chinese_processor.rb', line 26 def only_zh_cn?(char) @zh_cn.include?(char) end |
#only_zh_tw?(char) ⇒ Boolean
22 23 24 |
# File 'lib/unihan_lang/chinese_processor.rb', line 22 def only_zh_tw?(char) @zh_tw.include?(char) && !@common.include?(char) end |
#zh_cn?(char) ⇒ Boolean
18 19 20 |
# File 'lib/unihan_lang/chinese_processor.rb', line 18 def zh_cn?(char) @zh_cn.include?(char) || @common.include?(char) end |
#zh_tw?(char) ⇒ Boolean
14 15 16 |
# File 'lib/unihan_lang/chinese_processor.rb', line 14 def zh_tw?(char) @zh_tw.include?(char) || @common.include?(char) end |