Class: Ucode::Glyphs::SourceBuilder
- Inherits:
-
Object
- Object
- Ucode::Glyphs::SourceBuilder
- Defined in:
- lib/ucode/glyphs/source_builder.rb
Overview
Builds Source instances by joining a SourceConfig (block → font mapping) with a Database (block name → codepoint range).
This is the single place that knows how to turn configuration + UCD metadata into live Source objects. Keeping that knowledge out of SourceConfig (which is a pure data loader) and out of Resolver (which is a pure orchestrator) keeps each class's responsibility narrow.
For each block with at least one Tier 1 source in the config, the builder resolves the block's codepoint range from the UCD database and constructs one Ucode::Glyphs::Sources::Tier1RealFont per configured Models::GlyphSource. Blocks in the config that aren't in the UCD database are silently skipped — they may be future blocks or typos, and either way there's no range to serve.
Instance Method Summary collapse
-
#initialize(config:, database:) ⇒ SourceBuilder
constructor
A new instance of SourceBuilder.
-
#tier1_sources(install: true) ⇒ Array<Source>
One Tier1RealFont per (block, source) pair in the config whose block exists in the UCD database.
Constructor Details
#initialize(config:, database:) ⇒ SourceBuilder
Returns a new instance of SourceBuilder.
29 30 31 32 |
# File 'lib/ucode/glyphs/source_builder.rb', line 29 def initialize(config:, database:) @config = config @database = database end |
Instance Method Details
#tier1_sources(install: true) ⇒ Array<Source>
Returns one Tier1RealFont per (block, source) pair in the config whose block exists in the UCD database.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ucode/glyphs/source_builder.rb', line 38 def tier1_sources(install: true) @config.configured_block_ids.flat_map do |block_id| range = block_range_for(block_id) next [] unless range @config.fonts_for(block_id).map do |source| Sources::Tier1RealFont.new(block_range: range, source: source, install: install) end end end |