Class: OoxmlParser::CommentAuthors

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb

Overview

Class for parsing ‘commentAuthors.xml` file

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ CommentAuthors

Returns a new instance of CommentAuthors.



10
11
12
13
# File 'lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb', line 10

def initialize(parent: nil)
  @list = []
  super
end

Instance Attribute Details

#listArray<CommentAuthor> (readonly)

Returns list of comment authors.

Returns:



8
9
10
# File 'lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb', line 8

def list
  @list
end

Instance Method Details

#author_by_id(id) ⇒ CommentAuthor

Returns author by id.

Parameters:

  • id (Integer)

    id of author

Returns:



35
36
37
# 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 = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/commentAuthors.xml") ⇒ CommentAuthors

Parse CommentAuthors object

Parameters:

  • file (Nokogiri::XML:Element) (defaults to: "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/commentAuthors.xml")

    node to parse

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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