Sha256: 87692f7419ee9ecf4760f77d0fa243c8884cb775f46fe93ad7a187e969a845e5

Contents?: true

Size: 758 Bytes

Versions: 3

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

module OoxmlParser
  # Comment Data
  class Comment < OOXMLDocumentObject
    # @return [Integer] id of comment
    attr_reader :id
    # @return [Array<DocxParagraph>] array of paragraphs
    attr_reader :paragraphs

    def initialize(id = nil, paragraphs = [], parent: nil)
      @id = id
      @paragraphs = paragraphs
      @parent = parent
    end

    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'id'
          @id = value.value.to_i
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'p'
          @paragraphs << DocxParagraph.new.parse(node_child, 0, parent: self)
        end
      end
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ooxml_parser-0.6.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb
ooxml_parser-0.5.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb
ooxml_parser-0.5.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb