Method: EastAsianWidthSimple#initialize
- Defined in:
- lib/east_asian_width_simple.rb
#initialize(east_asian_width_txt_io) ⇒ EastAsianWidthSimple
Returns a new instance of EastAsianWidthSimple.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/east_asian_width_simple.rb', line 10 def initialize(east_asian_width_txt_io) @lookup_table = Array.new(2**21) east_asian_width_txt_io.each_line do |line| next unless line.start_with?(HEX_DIGIT_REGEXP) code_point, property = line.split(' ').first.split(';') if code_point.include?('..') first, last = code_point.split('..') @lookup_table.fill(property.to_sym, first.to_i(16)..last.to_i(16)) else @lookup_table[code_point.to_i(16)] = property.to_sym end end end |