Class: OoxmlParser::PresentationComment

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb

Overview

Class for parsing ‘p:cm` tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#author_idInteger (readonly)

Returns id of author.

Returns:

  • (Integer)

    id of author



7
8
9
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb', line 7

def author_id
  @author_id
end

#positionOOXMLCoordinates (readonly)

Returns position of comment.

Returns:



9
10
11
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb', line 9

def position
  @position
end

#textString (readonly)

Returns text of comment.

Returns:

  • (String)

    text of comment



11
12
13
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb', line 11

def text
  @text
end

Instance Method Details

#authorCommentAuthor

Returns author of comment.

Returns:



14
15
16
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb', line 14

def author
  root_object.comment_authors.author_by_id(@author_id)
end

#parse(node) ⇒ PresentationComment

Parse PresentationComment object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ooxml_parser/pptx_parser/presentation/presentation_comments/presentation_comment.rb', line 21

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'authorId'
      @author_id = value.value.to_i
    end
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'pos'
      @position = OOXMLCoordinates.new(parent: self).parse(node_child)
    when 'text'
      @text = node_child.text.to_s
    end
  end
  self
end