summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/worksheet_comments.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-08-04 14:57:43 +0900
committerRandy Morgan <[email protected]>2012-08-04 14:57:43 +0900
commit3e6b3f3f59dfebb18f1791d2bc8e3815cd46e519 (patch)
treeeb6fe11e8ccea7edf8c1f84c065c3f3c9ad9045e /lib/axlsx/workbook/worksheet/worksheet_comments.rb
parentdd91d5088c8137070c2862ee4afc1a452628c893 (diff)
downloadcaxlsx-3e6b3f3f59dfebb18f1791d2bc8e3815cd46e519.tar.gz
caxlsx-3e6b3f3f59dfebb18f1791d2bc8e3815cd46e519.zip
pre-release prep
clean up .yardops and basic documentation for serialization helpers
Diffstat (limited to 'lib/axlsx/workbook/worksheet/worksheet_comments.rb')
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet_comments.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet_comments.rb b/lib/axlsx/workbook/worksheet/worksheet_comments.rb
index 25ddb024..8c700aa0 100644
--- a/lib/axlsx/workbook/worksheet/worksheet_comments.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet_comments.rb
@@ -1,35 +1,54 @@
module Axlsx
- #A wraper class for comments that defines its on worksheet
- #serailization
+ # A wraper class for comments that defines its on worksheet
+ # serailization
class WorksheetComments
+ # Creates a new WorksheetComments object
+ # param [Worksheet] worksheet The worksheet comments in thes object belong to
def initialize(worksheet)
raise ArugumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet)
@worksheet = worksheet
end
+
attr_reader :worksheet
+ # The comments for this worksheet.
+ # @return [Comments]
def comments
@comments ||= Comments.new(worksheet)
end
+ # Adds a comment
+ # @param [Hash] options
+ # @see Comments#add_comment
def add_comment(options={})
comments.add_comment(options)
end
+ # The relationships defined by this objects comments collection
+ # @return [Relationships]
def relationships
return [] unless has_comments?
comments.relationships
end
+
+ # Helper method to tell us if there are comments in the comments collection
+ # @return [Boolean]
def has_comments?
!comments.empty?
end
+ # The index in the worksheet's relationships for the VML drawing that will render the comments
+ # @return [Integer]
def index
worksheet.relationships.index { |r| r.Type == VML_DRAWING_R } + 1
end
+
+ # Seraalize the object
+ # @param [String] str
+ # @return [String]
def to_xml_string(str = '')
return unless has_comments?
str << "<legacyDrawing r:id='rId#{index}' />"