Class: Uniword::Transformation::RunTransformationRule
- Inherits:
-
TransformationRule
- Object
- TransformationRule
- Uniword::Transformation::RunTransformationRule
- Defined in:
- lib/uniword/transformation/run_transformation_rule.rb
Overview
Transformation rule for Run elements.
Responsibility: Transform Run objects between DOCX and MHTML formats. Single Responsibility - handles only Run transformations.
Transformations preserve text content and formatting properties. Format-specific properties are adapted as needed.
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_run) ⇒ Run
Transform a run 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
23 24 25 26 27 |
# File 'lib/uniword/transformation/run_transformation_rule.rb', line 23 def matches?(element_type:, source_format:, target_format:) element_type == Run && source_format == @source_format && target_format == @target_format end |
#transform(source_run) ⇒ Run
Transform a run from source format to target format
Creates new Run with same text and adapted properties.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/uniword/transformation/run_transformation_rule.rb', line 36 def transform(source_run) validate_element_type(source_run, Run) # Create new run with same text target_run = Run.new(text: source_run.text) # Transform properties if they exist transform_properties(source_run, target_run) if source_run.properties target_run end |