Sha256: 4356c4f1ba04bdc0ff1078d4ae1c4cdcda41e724e6be338bfdd0fb5704ede1c2
Contents?: true
Size: 1.91 KB
Versions: 3
Compression:
Stored size: 1.91 KB
Contents
module Axlsx class Comments # a collection of the comment authors # @return [SimpleTypedList] attr_reader :authors # a collection of comment objects # @return [SimpleTypedList] attr_reader :comment_list # The worksheet that these comments belong to # @return [Worksheet] attr_reader :worksheet # Creates a new Comments object def initialize(worksheet) raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet) @worksheet = worksheet @authors = SimpleTypedList.new String @comment_list = SimpleTypedList.new Comment end def add_comment(options={}) raise ArgumentError, "Comment require an author" unless options[:author] raise ArgumentError, "Comment requires text" unless options[:text] options[:author_index] = @authors.index(options[:author]) || @authors << options[:author] @comment_list << Comment.new(self, options) @comment_list.last end def to_xml_string(str="") end end class Comment attr_reader :text attr_reader :author_index attr_reader :comments # TODO # r (Rich Text Run) # 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 def pn "#{COMMENT_PN % (index+1)}" end # The index of this comment # @return [Integer] def index @comments.comment_list.index(self) end def text=(v) Axlsx::validate_string(v) @text = v end def author_index=(v) Axlsx::validate_unsigned_int(v) @author_index = v end def to_xml_string(str = "") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
axlsx-1.1.7 | lib/axlsx/workbook/worksheet/comments.rb~ |
axlsx-1.1.6 | lib/axlsx/workbook/worksheet/comments.rb~ |
axlsx-1.1.5 | lib/axlsx/workbook/worksheet/comments.rb~ |