Class: Ucode::Parsers::CjkRadicals

Inherits:
Base
  • Object
show all
Defined in:
lib/ucode/parsers/cjk_radicals.rb

Overview

Parses CJKRadicals.txt — KangXi radical → CJK radical ideograph → canonical ideograph mapping.

Format (UAX #44):

radical_number; cjk_radical; ideograph

cjk_radical and ideograph are either a single hex codepoint (2F00) or a range in the form XXXX..YYYY. Range rows are expanded to one CjkRadical per codepoint.

Coordinator merges each row into the relevant CodePoint.

Class Method Summary collapse

Methods inherited from Base

each_line, parse_codepoint_or_range, parse_field, parse_hex_cp

Class Method Details

.each_record(path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ucode/parsers/cjk_radicals.rb', line 21

def each_record(path)
  return enum_for(:each_record, path) unless block_given?

  each_line(path) do |line|
    fields = line.fields
    next if fields.length < 3

    radical_number = parse_radical_number(fields[0])
    cjk_radical_field = fields[1]
    ideograph_field = fields[2]
    next if radical_number.nil?

    yield_models(radical_number, cjk_radical_field, ideograph_field).each do |model|
      yield model
    end
  end

  nil
end