Class: Uniword::Transformation::HyperlinkTransformationRule
- Inherits:
-
TransformationRule
- Object
- TransformationRule
- Uniword::Transformation::HyperlinkTransformationRule
- Defined in:
- lib/uniword/transformation/hyperlink_transformation_rule.rb
Overview
Transformation rule for Hyperlink elements.
Responsibility: Transform Hyperlink objects between DOCX and MHTML formats. Single Responsibility - handles only Hyperlink transformations.
Transforms hyperlinks including URL, anchor, tooltip, and contained runs.
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_link) ⇒ Hyperlink
Transform a hyperlink 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/hyperlink_transformation_rule.rb', line 22 def matches?(element_type:, source_format:, target_format:) element_type == Hyperlink && source_format == @source_format && target_format == @target_format end |
#transform(source_link) ⇒ Hyperlink
Transform a hyperlink from source format to target format
Creates new Hyperlink with same URL/anchor and transformed runs.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/uniword/transformation/hyperlink_transformation_rule.rb', line 35 def transform(source_link) validate_element_type(source_link, Hyperlink) # Create new hyperlink with core properties target_link = Hyperlink.new( url: source_link.url, anchor: source_link.anchor, text: source_link.text, tooltip: source_link.tooltip, relationship_id: source_link.relationship_id, ) # Transform runs within hyperlink transform_runs(source_link, target_link) target_link end |