Class: Axlsx::WorksheetComments
- Inherits:
-
Object
- Object
- Axlsx::WorksheetComments
- Defined in:
- lib/axlsx/workbook/worksheet/worksheet_comments.rb
Overview
A wraper class for comments that defines its on worksheet serailization
Instance Attribute Summary collapse
-
#worksheet ⇒ Object
readonly
Returns the value of attribute worksheet.
Instance Method Summary collapse
-
#add_comment(options = {}) ⇒ Object
Adds a comment.
-
#comments ⇒ Comments
The comments for this worksheet.
-
#drawing_rId ⇒ String
The relationship id of the VML drawing that will render the comments.
-
#has_comments? ⇒ Boolean
Helper method to tell us if there are comments in the comments collection.
-
#initialize(worksheet) ⇒ WorksheetComments
constructor
Creates a new WorksheetComments object param [Worksheet] worksheet The worksheet comments in thes object belong to.
-
#relationships ⇒ Relationships
The relationships defined by this objects comments collection.
-
#to_xml_string(str = +'')) ⇒ String
Seraalize the object.
Constructor Details
#initialize(worksheet) ⇒ WorksheetComments
Creates a new WorksheetComments object param [Worksheet] worksheet The worksheet comments in thes object belong to
9 10 11 12 13 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 9 def initialize(worksheet) raise ArugumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet) @worksheet = worksheet end |
Instance Attribute Details
#worksheet ⇒ Object (readonly)
Returns the value of attribute worksheet.
15 16 17 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 15 def worksheet @worksheet end |
Instance Method Details
#add_comment(options = {}) ⇒ Object
Adds a comment
26 27 28 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 26 def add_comment( = {}) comments.add_comment() end |
#comments ⇒ Comments
The comments for this worksheet.
19 20 21 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 19 def comments @comments ||= Comments.new(worksheet) end |
#drawing_rId ⇒ String
The relationship id of the VML drawing that will render the comments.
47 48 49 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 47 def drawing_rId comments.relationships.find { |r| r.Type == VML_DRAWING_R }.Id end |
#has_comments? ⇒ Boolean
Helper method to tell us if there are comments in the comments collection
40 41 42 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 40 def has_comments? # rubocop:disable Naming/PredicateName !comments.empty? end |
#relationships ⇒ Relationships
The relationships defined by this objects comments collection
32 33 34 35 36 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 32 def relationships return [] unless has_comments? comments.relationships end |
#to_xml_string(str = +'')) ⇒ String
Seraalize the object
54 55 56 57 58 |
# File 'lib/axlsx/workbook/worksheet/worksheet_comments.rb', line 54 def to_xml_string(str = +'') return unless has_comments? str << "<legacyDrawing r:id='#{drawing_rId}' />" end |