Class: Ucode::Glyphs::PdfFetcher
- Inherits:
-
Object
- Object
- Ucode::Glyphs::PdfFetcher
- Defined in:
- lib/ucode/glyphs/pdf_fetcher.rb
Overview
Resolves a Unicode block to its source PDF on disk.
Primary source: the per-block PDF cached at ‘<cache>/<version>/pdfs/U<XXXX>.pdf` (downloaded from `unicode.org/charts/PDF/` by `Ucode::Fetch::CodeCharts`).
Fallback: slice the page range from the monolith ‘CodeCharts.pdf`. The page range is resolved by `MonolithPageMap` from the PDF’s bookmark outline, cached under ‘data/codecharts_page_map.json`.
Instance Method Summary collapse
-
#fetch(block_first_cp:, force: false) ⇒ Pathname?
Resolve the per-block PDF for ‘block_first_cp`, fetching from the network if missing.
-
#initialize(version, monolith_path: nil, blocks: [], page_map_cache: nil) ⇒ PdfFetcher
constructor
A new instance of PdfFetcher.
Constructor Details
#initialize(version, monolith_path: nil, blocks: [], page_map_cache: nil) ⇒ PdfFetcher
Returns a new instance of PdfFetcher.
29 30 31 32 33 34 |
# File 'lib/ucode/glyphs/pdf_fetcher.rb', line 29 def initialize(version, monolith_path: nil, blocks: [], page_map_cache: nil) @version = version @monolith_path = monolith_path && Pathname.new(monolith_path) @blocks = blocks @page_map_cache = page_map_cache end |
Instance Method Details
#fetch(block_first_cp:, force: false) ⇒ Pathname?
Resolve the per-block PDF for ‘block_first_cp`, fetching from the network if missing. Returns the local PDF path, or nil if the block’s PDF is unavailable (network failure + no monolith, or monolith lacks the requested block).
45 46 47 48 49 50 51 52 53 |
# File 'lib/ucode/glyphs/pdf_fetcher.rb', line 45 def fetch(block_first_cp:, force: false) path = per_block_path(block_first_cp) return path if path.exist? && !force download(block_first_cp) return path if path.exist? slice_from_monolith(block_first_cp) end |