Class: Ucode::Audit::BlockAggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/audit/block_aggregator.rb

Overview

Produces one Models::Audit::BlockSummary per touched Unicode block for a font’s cmap codepoint set, compared against a ucode UCD baseline.

Pure transformation: takes the resolved baseline Database + the font’s codepoint list, returns BlockSummary[]. No I/O beyond the database lookups, no mutation of inputs.

The “assigned” set for a block is derived from the Database’s ranges-with-that-name. The Database stores coalesced runs of consecutive assigned codepoints grouped by block name, so the union of those ranges IS the assigned set for that block.

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ BlockAggregator

Returns a new instance of BlockAggregator.

Parameters:

  • database (Ucode::Database, nil)

    resolved baseline. When nil, #call returns an empty array — caller should treat that as “no UCD baseline available” and surface a warning.



21
22
23
# File 'lib/ucode/audit/block_aggregator.rb', line 21

def initialize(database)
  @database = database
end

Instance Method Details

#call(codepoints) ⇒ Array<Models::Audit::BlockSummary>

Returns sorted by first_cp.

Parameters:

  • codepoints (Enumerable<Integer>)

Returns:



27
28
29
30
31
32
33
# File 'lib/ucode/audit/block_aggregator.rb', line 27

def call(codepoints)
  return [] if @database.nil? || codepoints.empty?

  grouped = group_by_block(codepoints)
  grouped.map { |name, covered| build_summary(name, covered) }
    .sort_by(&:first_cp)
end