Class: Axlsx::Comment
- Inherits:
-
Object
- Object
- Axlsx::Comment
- Includes:
- Accessors, OptionsParser
- Defined in:
- lib/axlsx/workbook/worksheet/comment.rb
Overview
A comment is the text data for a comment
Instance Attribute Summary collapse
-
#comments ⇒ Comments
readonly
The owning Comments object.
-
#ref ⇒ String|Cell
The string based cell position reference (e.g. 'A1') that determines the positioning of this comment.
Instance Method Summary collapse
-
#author_index ⇒ Integer
The index of this author in a unique sorted list of all authors in the comment.
-
#initialize(comments, options = {}) {|_self| ... } ⇒ Comment
constructor
Creates a new comment object.
-
#to_xml_string(str = "") ⇒ String
serialize the object.
-
#vml_shape ⇒ VmlShape
The vml shape that will render this comment.
Methods included from OptionsParser
Constructor Details
#initialize(comments, options = {}) {|_self| ... } ⇒ Comment
Creates a new comment object
16 17 18 19 20 21 22 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 16 def initialize(comments, ={}) raise ArgumentError, "A comment needs a parent comments object" unless comments.is_a?(Comments) @visible = true @comments = comments yield self if block_given? end |
Instance Attribute Details
#comments ⇒ Comments (readonly)
The owning Comments object
29 30 31 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 29 def comments @comments end |
#ref ⇒ String|Cell
The string based cell position reference (e.g. 'A1') that determines the positioning of this comment
33 34 35 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 33 def ref @ref end |
Instance Method Details
#author_index ⇒ Integer
The index of this author in a unique sorted list of all authors in the comment.
49 50 51 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 49 def @comments..index() end |
#to_xml_string(str = "") ⇒ String
serialize the object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 63 def to_xml_string(str = "") = @comments.[] str << ('<comment ref="' << ref << '" authorId="' << .to_s << '">') str << '<text>' unless .to_s == "" str << '<r><rPr><b/><color indexed="81"/></rPr>' str << ("<t>" << ::CGI.escapeHTML(.to_s) << ":\n</t></r>") end str << '<r>' str << '<rPr><color indexed="81"/></rPr>' str << ('<t>' << ::CGI.escapeHTML(text) << '</t></r></text>') str << '</comment>' end |
#vml_shape ⇒ VmlShape
The vml shape that will render this comment
42 43 44 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 42 def vml_shape @vml_shape ||= initialize_vml_shape end |