diff options
| author | Randy Morgan <[email protected]> | 2012-10-14 12:25:09 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-10-14 12:25:09 +0900 |
| commit | 93b70a39999ac4d06e43e495f3fd283e9630d9d2 (patch) | |
| tree | bb2846edfc328ff9143c548c2a25eab23b8c9179 /lib/axlsx/workbook/worksheet/comment.rb | |
| parent | 5b5410845447772f4ba01b2ee5d03907f5897e7a (diff) | |
| download | caxlsx-93b70a39999ac4d06e43e495f3fd283e9630d9d2.tar.gz caxlsx-93b70a39999ac4d06e43e495f3fd283e9630d9d2.zip | |
Refactored to use options parser and serialized attributes.
Diffstat (limited to 'lib/axlsx/workbook/worksheet/comment.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/comment.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/axlsx/workbook/worksheet/comment.rb b/lib/axlsx/workbook/worksheet/comment.rb index bd7a88aa..3e54d2b3 100644 --- a/lib/axlsx/workbook/worksheet/comment.rb +++ b/lib/axlsx/workbook/worksheet/comment.rb @@ -3,6 +3,20 @@ module Axlsx # A comment is the text data for a comment class Comment + include Axlsx::OptionsParser + + # Creates a new comment object + # @param [Comments] comments + # @param [Hash] options + # @option [String] author the author of the comment + # @option [String] text The text for the comment + def initialize(comments, options={}) + raise ArgumentError, "A comment needs a parent comments object" unless comments.is_a?(Comments) + @comments = comments + parse_options options + yield self if block_given? + end + # The text to render # @return [String] attr_reader :text @@ -26,22 +40,12 @@ module Axlsx # rPh (Phonetic Text Run) # phoneticPr (Phonetic Properties) - def initialize(comments, options={}) - raise ArgumentError, "A comment needs a parent comments object" unless comments.is_a?(Comments) - @comments = comments - options.each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" - end - yield self if block_given? - end - # The vml shape that will render this comment # @return [VmlShape] def vml_shape @vml_shape ||= initialize_vml_shape end - # # The index of this author in a unique sorted list of all authors in # the comment. # @return [Integer] @@ -96,6 +100,5 @@ module Axlsx vml.bottom_row = vml.row + 4 end end - end end |
