Class: Fontist::FormatSpec
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Fontist::FormatSpec
- Defined in:
- lib/fontist/format_spec.rb
Overview
Encapsulates format requirements for font installation/lookup
Supports:
-
Format selection (install specific format)
-
Variable axes selection
-
Automatic transcoding (if format not available, transcode from available)
-
Transcode destination specification
This model is passed through the entire pipeline: CLI -> Font -> FormulaPicker -> FontInstaller -> Index
Class Method Summary collapse
-
.from_options(options = {}) ⇒ Object
Convenience constructor for CLI.
- .parse_variable_axes(value) ⇒ Object
Instance Method Summary collapse
-
#axes ⇒ Object
Get axes as array (never nil).
-
#has_constraints? ⇒ Boolean
Check if any format constraints are specified.
-
#needs_transcode?(available_formats) ⇒ Boolean
Check if transcoding might be needed (format specified but not available).
-
#specific_collection_index? ⇒ Boolean
Check if we need a specific collection index.
-
#variable_requested? ⇒ Boolean
Check if variable font is requested.
Class Method Details
.from_options(options = {}) ⇒ Object
Convenience constructor for CLI
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fontist/format_spec.rb', line 34 def self.( = {}) new( format: [:format], variable_axes: parse_variable_axes([:variable_axes]), prefer_variable: [:prefer_variable] || false, prefer_format: [:prefer_format], transcode_path: [:transcode_path], keep_original: .fetch(:keep_original, true), collection_index: [:collection_index], ) end |
.parse_variable_axes(value) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/fontist/format_spec.rb', line 46 def self.parse_variable_axes(value) return nil if value.nil? return value if value.is_a?(Array) value.to_s.split(",").map(&:strip).compact end |
Instance Method Details
#axes ⇒ Object
Get axes as array (never nil)
64 65 66 |
# File 'lib/fontist/format_spec.rb', line 64 def axes Array(variable_axes) end |
#has_constraints? ⇒ Boolean
Check if any format constraints are specified
54 55 56 |
# File 'lib/fontist/format_spec.rb', line 54 def has_constraints? !!(format || variable_axes&.any? || prefer_variable || prefer_format) end |
#needs_transcode?(available_formats) ⇒ Boolean
Check if transcoding might be needed (format specified but not available)
69 70 71 72 73 |
# File 'lib/fontist/format_spec.rb', line 69 def needs_transcode?(available_formats) return false unless format !available_formats.include?(format) end |
#specific_collection_index? ⇒ Boolean
Check if we need a specific collection index
76 77 78 |
# File 'lib/fontist/format_spec.rb', line 76 def specific_collection_index? !collection_index.nil? end |
#variable_requested? ⇒ Boolean
Check if variable font is requested
59 60 61 |
# File 'lib/fontist/format_spec.rb', line 59 def variable_requested? !!(variable_axes&.any? || prefer_variable) end |