Class: Fontisan::Audit::Context
- Inherits:
-
Object
- Object
- Fontisan::Audit::Context
- Defined in:
- lib/fontisan/audit/context.rb
Overview
Value object carrying everything an extractor needs to do its job.
Extractors never reach back into AuditCommand state — they read exclusively from the Context. Shared derived data (codepoints, UCD indices, source format) is memoized here so multiple extractors don't recompute it.
Instance Attribute Summary collapse
-
#font ⇒ Object
readonly
Returns the value of attribute font.
-
#font_index ⇒ Object
readonly
Returns the value of attribute font_index.
-
#font_path ⇒ Object
readonly
Returns the value of attribute font_path.
-
#num_fonts_in_source ⇒ Object
readonly
Returns the value of attribute num_fonts_in_source.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #all_codepoints? ⇒ Boolean
- #cldr ⇒ Object
- #codepoints ⇒ Object
-
#initialize(font:, font_path:, font_index:, num_fonts_in_source:, options:) ⇒ Context
constructor
A new instance of Context.
- #source_format ⇒ Object
- #ucd ⇒ Object
Constructor Details
#initialize(font:, font_path:, font_index:, num_fonts_in_source:, options:) ⇒ Context
Returns a new instance of Context.
15 16 17 18 19 20 21 22 |
# File 'lib/fontisan/audit/context.rb', line 15 def initialize(font:, font_path:, font_index:, num_fonts_in_source:, options:) @font = font @font_path = font_path @font_index = font_index @num_fonts_in_source = num_fonts_in_source @options = end |
Instance Attribute Details
#font ⇒ Object (readonly)
Returns the value of attribute font.
12 13 14 |
# File 'lib/fontisan/audit/context.rb', line 12 def font @font end |
#font_index ⇒ Object (readonly)
Returns the value of attribute font_index.
12 13 14 |
# File 'lib/fontisan/audit/context.rb', line 12 def font_index @font_index end |
#font_path ⇒ Object (readonly)
Returns the value of attribute font_path.
12 13 14 |
# File 'lib/fontisan/audit/context.rb', line 12 def font_path @font_path end |
#num_fonts_in_source ⇒ Object (readonly)
Returns the value of attribute num_fonts_in_source.
12 13 14 |
# File 'lib/fontisan/audit/context.rb', line 12 def num_fonts_in_source @num_fonts_in_source end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/fontisan/audit/context.rb', line 12 def @options end |
Instance Method Details
#all_codepoints? ⇒ Boolean
42 43 44 |
# File 'lib/fontisan/audit/context.rb', line 42 def all_codepoints? @options[:all_codepoints] == true end |
#cldr ⇒ Object
32 33 34 35 36 |
# File 'lib/fontisan/audit/context.rb', line 32 def cldr return nil unless @options[:with_language_coverage] @cldr ||= resolve_cldr end |
#codepoints ⇒ Object
24 25 26 |
# File 'lib/fontisan/audit/context.rb', line 24 def codepoints @codepoints ||= extract_codepoints end |
#source_format ⇒ Object
38 39 40 |
# File 'lib/fontisan/audit/context.rb', line 38 def source_format @source_format ||= FontLoader.detect_format(@font_path)&.to_s end |
#ucd ⇒ Object
28 29 30 |
# File 'lib/fontisan/audit/context.rb', line 28 def ucd @ucd ||= resolve_ucd end |