Class: Fontisan::Export::Exporter
- Inherits:
-
Object
- Object
- Fontisan::Export::Exporter
- Defined in:
- lib/fontisan/export/exporter.rb
Overview
Exporter orchestrates font export to YAML/JSON/TTX
Main entry point for exporting fonts to debugging formats. Handles table extraction, serialization, and metadata generation.
Instance Method Summary collapse
-
#export(options = {}) ⇒ Models::FontExport, String
Export font to FontExport model.
-
#initialize(font, source_path, options = {}) ⇒ Exporter
constructor
Initialize exporter.
-
#to_json(options = {}) ⇒ String
Export font and return as JSON string.
-
#to_ttx(options = {}) ⇒ String
Export font and return as TTX XML string.
-
#to_yaml(options = {}) ⇒ String
Export font and return as YAML string.
Constructor Details
#initialize(font, source_path, options = {}) ⇒ Exporter
Initialize exporter
35 36 37 38 39 40 |
# File 'lib/fontisan/export/exporter.rb', line 35 def initialize(font, source_path, = {}) @font = font @source_path = source_path @binary_format = .fetch(:binary_format, :hex) @serializer = TableSerializer.new(binary_format: @binary_format) end |
Instance Method Details
#export(options = {}) ⇒ Models::FontExport, String
Export font to FontExport model
48 49 50 51 52 53 54 55 56 |
# File 'lib/fontisan/export/exporter.rb', line 48 def export( = {}) format = [:format] || :yaml if format == :ttx to_ttx() else export_to_model() end end |
#to_json(options = {}) ⇒ String
Export font and return as JSON string
71 72 73 74 |
# File 'lib/fontisan/export/exporter.rb', line 71 def to_json( = {}) export_model = export_to_model() export_model.to_json end |
#to_ttx(options = {}) ⇒ String
Export font and return as TTX XML string
Uses model-based architecture with FontToTtx transformer and lutaml-model serialization.
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/fontisan/export/exporter.rb', line 86 def to_ttx( = {}) # Use new model-based architecture transformer = Transformers::FontToTtx.new(@font) ttx_model = transformer.transform() # Let lutaml-model handle XML serialization ttx_model.to_xml( pretty: .fetch(:pretty, true), indent: .fetch(:indent, 2), ) end |
#to_yaml(options = {}) ⇒ String
Export font and return as YAML string
62 63 64 65 |
# File 'lib/fontisan/export/exporter.rb', line 62 def to_yaml( = {}) export_model = export_to_model() export_model.to_yaml end |