class OoxmlParser::CommentAuthors

Class for parsing ‘commentAuthors.xml` file

Attributes

list[R]

@return [Array<CommentAuthor>] list of comment authors

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb, line 10
def initialize(parent: nil)
  @list = []
  super
end

Public Instance Methods

author_by_id(id) click to toggle source

@param id [Integer] id of author @return [CommentAuthor] author by id

# File lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb, line 35
def author_by_id(id)
  list.detect { |author| author.id == id }
end
parse(file = " click to toggle source

Parse CommentAuthors object @param file [Nokogiri::XML:Element] node to parse @return [CommentAuthors] result of parsing

# File lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb, line 18
def parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/commentAuthors.xml")
  return nil unless File.exist?(file)

  document = parse_xml(file)
  node = document.xpath('*').first

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'cmAuthor'
      @list << CommentAuthor.new(parent: self).parse(node_child)
    end
  end
  self
end