Sha256: 0f3afeb05c367d19b36cdb056daa0ec0052bf151b4b08d0bfe175411068da51f

Contents?: true

Size: 883 Bytes

Versions: 5

Compression:

Stored size: 883 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

    # Parse Comment object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [Comment] result of parsing
    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

5 entries across 5 versions & 1 rubygems

Version Path
ooxml_parser-0.8.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb
ooxml_parser-0.8.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb
ooxml_parser-0.7.2 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb
ooxml_parser-0.7.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb
ooxml_parser-0.7.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb