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.
Source: the per-block PDF cached at
<cache>/<version>/pdfs/U<XXXX>.pdf (downloaded from
unicode.org/charts/PDF/ by Ucode::Fetch::CodeCharts).
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) ⇒ PdfFetcher
constructor
A new instance of PdfFetcher.
Constructor Details
#initialize(version) ⇒ PdfFetcher
Returns a new instance of PdfFetcher.
17 18 19 |
# File 'lib/ucode/glyphs/pdf_fetcher.rb', line 17 def initialize(version) @version = version 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).
29 30 31 32 33 34 35 |
# File 'lib/ucode/glyphs/pdf_fetcher.rb', line 29 def fetch(block_first_cp:, force: false) path = per_block_path(block_first_cp) return path if path.exist? && !force download(block_first_cp) path if path.exist? end |