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
-
#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)
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
34 35 36 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 34 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.
50 51 52 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 50 def @comments..index() end |
#to_xml_string(str = "") ⇒ String
serialize the object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 64 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
43 44 45 |
# File 'lib/axlsx/workbook/worksheet/comment.rb', line 43 def vml_shape @vml_shape ||= initialize_vml_shape end |