Sha256: 0ca22b791a70a8d682b602afacf3dff05154e0049a575af25a83c1103836f5e3

Contents?: true

Size: 1.15 KB

Versions: 28

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require_relative 'comments_extended/comment_extended'
module OoxmlParser
  # Class for parsing `commentsExtended.xml` file
  class CommentsExtended < OOXMLDocumentObject
    def initialize(parent: nil)
      @comments_extended_array = []
      super
    end

    # @return [Array, CommentsExtended] accessor
    def [](key)
      @comments_extended_array[key]
    end

    # Parse CommentsExtended object
    # @return [CommentsExtended] result of parsing
    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

    # @param id [Integer] id of comment
    # @return [CommentExtended] comment by id
    def by_id(id)
      @comments_extended_array.each do |cur_comment|
        return cur_comment if cur_comment.paragraph_id == id
      end
      nil
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ooxml_parser-0.29.0 lib/ooxml_parser/docx_parser/document_structure/comments_extended.rb
ooxml_parser-0.28.0 lib/ooxml_parser/docx_parser/document_structure/comments_extended.rb
ooxml_parser-0.27.0 lib/ooxml_parser/docx_parser/document_structure/comments_extended.rb
ooxml_parser-0.26.0 lib/ooxml_parser/docx_parser/document_structure/comments_extended.rb
ooxml_parser-0.25.0 lib/ooxml_parser/docx_parser/document_structure/comments_extended.rb
ooxml_parser-0.24.0 lib/ooxml_parser/docx_parser/document_structure/comments_extended.rb
ooxml_parser-0.23.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.22.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.21.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.20.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.19.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.18.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.18.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.17.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.16.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.15.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.14.2 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.14.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
ooxml_parser-0.14.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb