Class: Uniword::CommentRange
- Defined in:
- lib/uniword/comment_range.rb
Overview
Represents a comment range marker in a Word document.
Comments in Word documents are anchored to specific text ranges using commentRangeStart and commentRangeEnd markers. These markers define the beginning and end of the commented text.
In OOXML:
-
<w:commentRangeStart> marks the start of a commented range
-
<w:commentRangeEnd> marks the end of a commented range
-
<w:commentReference> provides the actual link to the comment
Instance Attribute Summary collapse
-
#comment_id ⇒ String
The ID of the associated comment.
-
#marker_type ⇒ Object
Type of marker (:start, :end, :reference).
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
Accept a visitor for the visitor pattern.
-
#end? ⇒ Boolean
Check if this is an end marker.
-
#initialize(attributes = {}) ⇒ CommentRange
constructor
Initialize a comment range marker.
-
#inspect ⇒ String
Provide detailed inspection for debugging.
-
#reference? ⇒ Boolean
Check if this is a reference marker.
-
#start? ⇒ Boolean
Check if this is a start marker.
-
#valid? ⇒ Boolean
Check if the comment range is valid.
-
#xml_element_name ⇒ String
Get the XML element name based on marker type.
Methods inherited from Element
Constructor Details
#initialize(attributes = {}) ⇒ CommentRange
Initialize a comment range marker
49 50 51 52 |
# File 'lib/uniword/comment_range.rb', line 49 def initialize(attributes = {}) @marker_type = attributes.delete(:marker_type) || :start super end |
Instance Attribute Details
#comment_id ⇒ String
The ID of the associated comment
29 30 31 |
# File 'lib/uniword/comment_range.rb', line 29 def comment_id @comment_id end |
#marker_type ⇒ Object
Type of marker (:start, :end, :reference)
29 30 31 |
# File 'lib/uniword/comment_range.rb', line 29 def marker_type @marker_type end |
Instance Method Details
#accept(visitor) ⇒ Object
Accept a visitor for the visitor pattern
58 59 60 |
# File 'lib/uniword/comment_range.rb', line 58 def accept(visitor) visitor.visit_comment_range(self) end |
#end? ⇒ Boolean
Check if this is an end marker
72 73 74 |
# File 'lib/uniword/comment_range.rb', line 72 def end? marker_type == :end end |
#inspect ⇒ String
Provide detailed inspection for debugging
109 110 111 |
# File 'lib/uniword/comment_range.rb', line 109 def inspect "#<Uniword::CommentRange type=#{marker_type.inspect} comment_id=#{comment_id.inspect}>" end |
#reference? ⇒ Boolean
Check if this is a reference marker
79 80 81 |
# File 'lib/uniword/comment_range.rb', line 79 def reference? marker_type == :reference end |
#start? ⇒ Boolean
Check if this is a start marker
65 66 67 |
# File 'lib/uniword/comment_range.rb', line 65 def start? marker_type == :start end |
#valid? ⇒ Boolean
Check if the comment range is valid
86 87 88 |
# File 'lib/uniword/comment_range.rb', line 86 def valid? required_attributes_valid? end |
#xml_element_name ⇒ String
Get the XML element name based on marker type
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/uniword/comment_range.rb', line 93 def xml_element_name case marker_type when :start "commentRangeStart" when :end "commentRangeEnd" when :reference "commentReference" else raise ArgumentError, "Invalid marker type: #{marker_type}" end end |