Class: Ucode::Parsers::DerivedCoreProperties

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

Overview

Parses ‘DerivedCoreProperties.txt` — derived binary properties (Alphabetic, Uppercase, White_Space, Bidi_Control, …).

Format (UAX #44):

XXXX..YYYY; Property_Name
XXXX; Property_Name

The file only lists positive assignments; absence means the property is false. Each yielded ‘BinaryPropertyAssignment` has `enabled: true`.

Coordinator appends each ‘property_short` (resolved to the long form via PropertyAliases if needed) to `CodePoint#binary_properties`.

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



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

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 < 2

    range = parse_codepoint_or_range(fields[0])
    property = fields[1]
    next if property.nil? || property.empty?

    each_cp(range) { |cp| yield build_assignment(cp, property) }
  end

  nil
end