Class: Ucode::Glyphs::LastResort::Contents
- Inherits:
-
Object
- Object
- Ucode::Glyphs::LastResort::Contents
- Defined in:
- lib/ucode/glyphs/last_resort/contents.rb
Overview
Parses the UFO ‘contents.plist` once into a `=> glif_basename` lookup.
The plist is the standard UFO v3 format:
<dict>
<key>lastresortlatin</key>
<string>lastresortlatin.glif</string>
...
</dict>
380 entries (one per placeholder glyph). Tiny file, but parsing it once per Writer avoids 380 redundant Nokogiri passes across the per-codepoint loop.
Class Method Summary collapse
-
.parse(path) ⇒ Hash{String=>String}
Parse the plist file at ‘path` and return a frozen Hash.
Instance Method Summary collapse
-
#[](glyph_name) ⇒ String?
Glif basename (e.g. “lastresortlatin.glif”).
-
#initialize(path) ⇒ Contents
constructor
A new instance of Contents.
- #key?(glyph_name) ⇒ Boolean
-
#to_h ⇒ Hash{String=>String}
Frozen glyph name → glif basename.
Constructor Details
#initialize(path) ⇒ Contents
Returns a new instance of Contents.
38 39 40 |
# File 'lib/ucode/glyphs/last_resort/contents.rb', line 38 def initialize(path) @path = Pathname.new(path) end |
Class Method Details
.parse(path) ⇒ Hash{String=>String}
Parse the plist file at ‘path` and return a frozen Hash.
33 34 35 |
# File 'lib/ucode/glyphs/last_resort/contents.rb', line 33 def self.parse(path) new(path).to_h end |
Instance Method Details
#[](glyph_name) ⇒ String?
Returns glif basename (e.g. “lastresortlatin.glif”).
49 50 51 |
# File 'lib/ucode/glyphs/last_resort/contents.rb', line 49 def [](glyph_name) to_h[glyph_name] end |
#key?(glyph_name) ⇒ Boolean
54 55 56 |
# File 'lib/ucode/glyphs/last_resort/contents.rb', line 54 def key?(glyph_name) to_h.key?(glyph_name) end |
#to_h ⇒ Hash{String=>String}
Returns frozen glyph name → glif basename.
43 44 45 |
# File 'lib/ucode/glyphs/last_resort/contents.rb', line 43 def to_h @to_h ||= build_index.freeze end |