Class: OoxmlParser::CommentsExtended
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::CommentsExtended
- Defined in:
- lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb
Overview
Class for parsing ‘commentsExtended.xml` file
Instance Attribute Summary
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#[](key) ⇒ Array, CommentsExtended
Accessor.
-
#by_id(id) ⇒ CommentExtended
Comment by id.
-
#initialize(parent: nil) ⇒ CommentsExtended
constructor
A new instance of CommentsExtended.
-
#parse ⇒ CommentsExtended
Parse CommentsExtended object.
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
Constructor Details
#initialize(parent: nil) ⇒ CommentsExtended
Returns a new instance of CommentsExtended.
5 6 7 8 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb', line 5 def initialize(parent: nil) @comments_extended_array = [] @parent = parent end |
Instance Method Details
#[](key) ⇒ Array, CommentsExtended
Returns accessor.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb', line 11 def [](key) @comments_extended_array[key] end |
#by_id(id) ⇒ CommentExtended
Returns comment by id.
32 33 34 35 36 37 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb', line 32 def by_id(id) @comments_extended_array.each do |cur_comment| return cur_comment if cur_comment.paragraph_id == id end nil end |
#parse ⇒ CommentsExtended
Parse CommentsExtended object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb', line 17 def parse file_to_parse = OOXMLDocumentObject.path_to_folder + 'word/commentsExtended.xml' return nil unless File.exist?(file_to_parse) doc = Nokogiri::XML(File.open(file_to_parse)) doc.xpath('w15:commentsEx/*').each do |node_child| case node_child.name when 'commentEx' @comments_extended_array << CommentExtended.new(parent: self).parse(node_child) end end self end |