Class: Ucode::Parsers::CaseFolding
- Defined in:
- lib/ucode/parsers/case_folding.rb
Overview
Parses ‘CaseFolding.txt` — case folding mappings for comparison.
Format (UAX #44):
cp; status; mapping; # name
‘status` is one of: C (common), F (full), S (simple), T (turkic). `mapping` is one or more space-separated hex codepoints.
Class Method Summary collapse
-
.each_record(path) ⇒ Object
Yields one CaseFoldingRule per non-comment line.
Methods inherited from Base
each_line, parse_codepoint_or_range, parse_field, parse_hex_cp
Class Method Details
.each_record(path) ⇒ Object
Yields one CaseFoldingRule per non-comment line. Returns a lazy Enumerator when called without a block.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ucode/parsers/case_folding.rb', line 19 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 cp = parse_hex_cp(fields[0]) status = fields[1] next if status.nil? || status.empty? yield Models::CaseFoldingRule.new( codepoint: cp, status: status, mapping_ids: parse_mapping(fields[2]), comment: line.comment ) end nil end |