Class: Uniword::Transformation::ParagraphTransformationRule
- Inherits:
-
TransformationRule
- Object
- TransformationRule
- Uniword::Transformation::ParagraphTransformationRule
- Defined in:
- lib/uniword/transformation/paragraph_transformation_rule.rb
Overview
Transformation rule for Paragraph elements.
Responsibility: Transform Paragraph objects between DOCX and MHTML formats. Single Responsibility - handles only Paragraph transformations.
Transformations handle format-specific property conversions:
-
DOCX → MHTML: Convert OOXML properties to CSS-compatible properties
-
MHTML → DOCX: Convert CSS properties to OOXML properties
Instance Attribute Summary
Attributes inherited from TransformationRule
#source_format, #target_format
Instance Method Summary collapse
-
#matches?(element_type:, source_format:, target_format:) ⇒ Boolean
Check if this rule matches the transformation request.
-
#transform(source_para) ⇒ Paragraph
Transform a paragraph from source format to target format.
Methods inherited from TransformationRule
Constructor Details
This class inherits a constructor from Uniword::Transformation::TransformationRule
Instance Method Details
#matches?(element_type:, source_format:, target_format:) ⇒ Boolean
Check if this rule matches the transformation request
24 25 26 27 28 |
# File 'lib/uniword/transformation/paragraph_transformation_rule.rb', line 24 def matches?(element_type:, source_format:, target_format:) element_type == Paragraph && source_format == @source_format && target_format == @target_format end |
#transform(source_para) ⇒ Paragraph
Transform a paragraph from source format to target format
Creates new Paragraph with adapted properties and transformed runs.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/uniword/transformation/paragraph_transformation_rule.rb', line 37 def transform(source_para) validate_element_type(source_para, Paragraph) target_para = Paragraph.new # Transform properties based on format direction transform_properties(source_para, target_para) # Transform runs (delegate to RunTransformationRule) transform_runs(source_para, target_para) target_para end |