class OoxmlParser::CommentsExtended

Class for parsing `commentsExtended.xml` file

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb, line 7
def initialize(parent: nil)
  @comments_extended_array = []
  super
end

Public Instance Methods

[](key) click to toggle source

@return [Array, CommentsExtended] accessor

# File lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb, line 13
def [](key)
  @comments_extended_array[key]
end
by_id(id) click to toggle source

@param id [Integer] id of comment @return [CommentExtended] comment by id

# File lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb, line 35
def by_id(id)
  @comments_extended_array.each do |cur_comment|
    return cur_comment if cur_comment.paragraph_id == id
  end
  nil
end
parse() click to toggle source

Parse CommentsExtended object @return [CommentsExtended] result of parsing

# File lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb, line 19
def parse
  file_to_parse = "#{OOXMLDocumentObject.path_to_folder}word/commentsExtended.xml"
  return nil unless File.exist?(file_to_parse)

  doc = parse_xml(file_to_parse)
  doc.xpath('w15:commentsEx/*').each do |node_child|
    case node_child.name
    when 'commentEx'
      @comments_extended_array << CommentExtended.new(parent: self).parse(node_child)
    end
  end
  self
end