Class: Fontisan::Audit::Context

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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 = options
end

Instance Attribute Details

#fontObject (readonly)

Returns the value of attribute font.



12
13
14
# File 'lib/fontisan/audit/context.rb', line 12

def font
  @font
end

#font_indexObject (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_pathObject (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_sourceObject (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

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/fontisan/audit/context.rb', line 12

def options
  @options
end

Instance Method Details

#all_codepoints?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fontisan/audit/context.rb', line 42

def all_codepoints?
  @options[:all_codepoints] == true
end

#cldrObject



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

#codepointsObject



24
25
26
# File 'lib/fontisan/audit/context.rb', line 24

def codepoints
  @codepoints ||= extract_codepoints
end

#source_formatObject



38
39
40
# File 'lib/fontisan/audit/context.rb', line 38

def source_format
  @source_format ||= FontLoader.detect_format(@font_path)&.to_s
end

#ucdObject



28
29
30
# File 'lib/fontisan/audit/context.rb', line 28

def ucd
  @ucd ||= resolve_ucd
end