Class: Uniword::Generation::DocumentGenerator
- Inherits:
-
Object
- Object
- Uniword::Generation::DocumentGenerator
- Defined in:
- lib/uniword/generation/document_generator.rb
Overview
Generates DOCX documents from structured content and style sources.
Combines a style source DOCX (provides styles), a style mapping (maps semantic element names to OOXML style names), and structured content (from YAML/Markdown) into a new DOCX file.
Instance Method Summary collapse
-
#generate(structured_content, output_path) ⇒ void
Generate a DOCX from structured content elements.
-
#initialize(style_source:, style_mapping: nil) ⇒ DocumentGenerator
constructor
Initialize the generator with style source and optional mapping.
Constructor Details
#initialize(style_source:, style_mapping: nil) ⇒ DocumentGenerator
Initialize the generator with style source and optional mapping.
24 25 26 27 |
# File 'lib/uniword/generation/document_generator.rb', line 24 def initialize(style_source:, style_mapping: nil) @style_source = style_source @mapper = StyleMapper.new(style_mapping) end |
Instance Method Details
#generate(structured_content, output_path) ⇒ void
This method returns an undefined value.
Generate a DOCX from structured content elements.
36 37 38 39 40 41 42 43 44 |
# File 'lib/uniword/generation/document_generator.rb', line 36 def generate(structured_content, output_path) builder = create_builder structured_content.each do |element| add_element(builder, element) end builder.save(output_path) end |