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
14 15 16 17 18 19 20 21 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 14 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
28 29 30 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 28 def comments @comments end |
#ref ⇒ String|Cell
The string based cell position reference (e.g. 'A1') that determines the positioning of this comment
32 33 34 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 32 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.
48 49 50 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 48 def @comments..index() end |
#to_xml_string(str = "") ⇒ String
serialize the object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 62 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
41 42 43 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 41 def vml_shape @vml_shape ||= initialize_vml_shape end |