Class: Uniword::Transformation::TableTransformationRule
- Inherits:
-
TransformationRule
- Object
- TransformationRule
- Uniword::Transformation::TableTransformationRule
- Defined in:
- lib/uniword/transformation/table_transformation_rule.rb
Overview
Transformation rule for Table elements.
Responsibility: Transform Table objects between DOCX and MHTML formats. Single Responsibility - handles only Table transformations.
Transforms table structure including rows, cells, and all 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_table) ⇒ Table
Transform a table 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
22 23 24 25 26 |
# File 'lib/uniword/transformation/table_transformation_rule.rb', line 22 def matches?(element_type:, source_format:, target_format:) element_type == Table && source_format == @source_format && target_format == @target_format end |
#transform(source_table) ⇒ Table
Transform a table from source format to target format
Creates new Table with all rows and cells transformed.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/uniword/transformation/table_transformation_rule.rb', line 35 def transform(source_table) validate_element_type(source_table, Table) target_table = Table.new # Transform table-level properties transform_properties(source_table, target_table) # Transform each row source_table.rows.each do |source_row| target_row = transform_row(source_row) target_table.rows << target_row end target_table end |