class OoxmlParser::Comments

Class for parsing `comments.xml` file

Attributes

comments_array[R]

@return [Array<Comment>] list of comments

Public Class Methods

new(params = {}) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/docx_parser/docx_data/document_structure/comments.rb, line 10
def initialize(params = {})
  @comments_array = []
  @file = params.fetch(:file, "#{OOXMLDocumentObject.path_to_folder}word/comments.xml")
  super(parent: params[:parent])
end

Public Instance Methods

[](key) click to toggle source

@return [Comment] accessor

# File lib/ooxml_parser/docx_parser/docx_data/document_structure/comments.rb, line 17
def [](key)
  @comments_array[key]
end
parse() click to toggle source

Parse CommentsExtended object @return [Comments] result of parsing

# File lib/ooxml_parser/docx_parser/docx_data/document_structure/comments.rb, line 23
def parse
  return nil unless File.file?(@file)

  doc = parse_xml(@file)
  doc.xpath('w:comments/*').each do |node_child|
    case node_child.name
    when 'comment'
      @comments_array << Comment.new(parent: self).parse(node_child)
    end
  end
  self
end