Class: OoxmlParser::Comment

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/docx_parser/document_structure/comments/comment.rb

Overview

Comment Data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(id = nil, paragraphs = [], parent: nil) ⇒ Comment

Returns a new instance of Comment.



11
12
13
14
15
# File 'lib/ooxml_parser/docx_parser/document_structure/comments/comment.rb', line 11

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

Instance Attribute Details

#idInteger (readonly)

Returns id of comment.

Returns:

  • (Integer)

    id of comment



7
8
9
# File 'lib/ooxml_parser/docx_parser/document_structure/comments/comment.rb', line 7

def id
  @id
end

#paragraphsArray<DocxParagraph> (readonly)

Returns array of paragraphs.

Returns:



9
10
11
# File 'lib/ooxml_parser/docx_parser/document_structure/comments/comment.rb', line 9

def paragraphs
  @paragraphs
end

Instance Method Details

#parse(node) ⇒ Comment

Parse Comment object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ooxml_parser/docx_parser/document_structure/comments/comment.rb', line 20

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