Class: OoxmlParser::PresentationComments

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

Overview

Class for parsing ‘comment1.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) ⇒ PresentationComments

Returns a new instance of PresentationComments.



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

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

Instance Attribute Details

#listArray<PresentationComment> (readonly)

Returns list of comments.

Returns:



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

def list
  @list
end

Instance Method Details

#parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/comments/comment1.xml") ⇒ PresentationComments

Parse PresentationComments object

Parameters:

  • file (Nokogiri::XML:Element) (defaults to: "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/comments/comment1.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/presentation_comments.rb', line 18

def parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/comments/comment1.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 'cm'
      @list << PresentationComment.new(parent: self).parse(node_child)
    end
  end
  self
end