Class: Unihan2
- Inherits:
-
Object
- Object
- Unihan2
- Defined in:
- lib/unihan2.rb
Constant Summary collapse
- DATA_DIR =
File.join(File.dirname(__FILE__), '../data')
Class Method Summary collapse
-
.chars_ver(xml_file_in, csv_file_out) ⇒ Object
將 Unicode XML 轉為 CSV, 內含 code range 的 unicode 版本.
Instance Method Summary collapse
-
#initialize ⇒ Unihan2
constructor
A new instance of Unihan2.
-
#strokes(char) ⇒ Integer
return total strokes of the character char.
-
#ver(code) ⇒ Float
return unicode version of specific character.
Constructor Details
#initialize ⇒ Unihan2
Returns a new instance of Unihan2.
6 7 8 9 |
# File 'lib/unihan2.rb', line 6 def initialize read_strokes read_version end |
Class Method Details
.chars_ver(xml_file_in, csv_file_out) ⇒ Object
將 Unicode XML 轉為 CSV, 內含 code range 的 unicode 版本
14 15 16 |
# File 'lib/unihan2.rb', line 14 def self.chars_ver(xml_file_in, csv_file_out) UnicodeCharsVer.new.convert(xml_file_in, csv_file_out) end |
Instance Method Details
#strokes(char) ⇒ Integer
return total strokes of the character char
21 22 23 |
# File 'lib/unihan2.rb', line 21 def strokes(char) @strokes[char] end |
#ver(code) ⇒ Float
return unicode version of specific character
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/unihan2.rb', line 28 def ver(code) return nil if code.nil? if code.is_a? Integer i = code elsif code.size == 1 i = code.codepoints.first else i = code.hex end ver_bsearch(i, 0, @vers.size-1) end |