Module: Ucode::Aggregator
- Defined in:
- lib/ucode/aggregator.rb
Overview
Coverage analysis over codepoint sets.
Pure transformations: given a collection of codepoints and an ‘Index` (blocks or scripts), return aggregated summaries. No I/O, no mutation of inputs, no global state.
OCP: new aggregation kinds (planes, categories, …) slot in as new methods without altering existing ones.
Defined Under Namespace
Classes: BlockSummary
Class Method Summary collapse
-
.aggregate_blocks(codepoints, blocks_index) ⇒ Array<BlockSummary>
One summary per block in the index, in the index’s natural (first_cp) order.
-
.aggregate_scripts(codepoints, scripts_index) ⇒ Array<String>
Sorted unique script names covering the given codepoints.
Class Method Details
.aggregate_blocks(codepoints, blocks_index) ⇒ Array<BlockSummary>
Returns one summary per block in the index, in the index’s natural (first_cp) order.
32 33 34 35 |
# File 'lib/ucode/aggregator.rb', line 32 def aggregate_blocks(codepoints, blocks_index) sorted = codepoints.sort blocks_index.map { |entry| build_block_summary(entry, sorted) } end |
.aggregate_scripts(codepoints, scripts_index) ⇒ Array<String>
Returns sorted unique script names covering the given codepoints.
41 42 43 |
# File 'lib/ucode/aggregator.rb', line 41 def aggregate_scripts(codepoints, scripts_index) codepoints.filter_map { |cp| scripts_index.lookup(cp) }.uniq.sort end |