Class: OoxmlParser::PresentationComment

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

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(author) ⇒ PresentationComment

Returns a new instance of PresentationComment.



6
7
8
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb', line 6

def initialize(author)
  @author = author
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



4
5
6
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb', line 4

def author
  @author
end

#positionObject

Returns the value of attribute position.



4
5
6
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb', line 4

def position
  @position
end

#textObject

Returns the value of attribute text.



4
5
6
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb', line 4

def text
  @text
end

Class Method Details

.parse(comment_node, comment_authors) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb', line 10

def self.parse(comment_node, comment_authors)
  comment = PresentationComment.new(comment_authors[comment_node.attribute('authorId').value])
  comment_node.xpath('*').each do |comment_node_child|
    case comment_node_child.name
    when 'pos'
      comment.position = OOXMLCoordinates.parse(comment_node_child, x_attr: 'x', y_attr: 'y')
    when 'text'
      comment.text = comment_node_child.text.to_s
    end
  end
  comment
end

.parse_listObject



23
24
25
26
27
28
29
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb', line 23

def self.parse_list
  File.exist?(OOXMLDocumentObject.path_to_folder + 'ppt/comments/comment1.xml') ? doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + '/ppt/comments/comment1.xml')) : (return [])
  comment_authors = PresentationCommentAuthor.parse
  comments = []
  doc.xpath('p:cmLst/p:cm').each { |comment_node| comments << PresentationComment.parse(comment_node, comment_authors) }
  comments
end