Class: OoxmlParser::Comment
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Comment
- Defined in:
- lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#paragraphs ⇒ Object
Returns the value of attribute paragraphs.
Attributes inherited from OOXMLDocumentObject
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id = nil, paragraphs = []) ⇒ Comment
constructor
A new instance of Comment.
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(id = nil, paragraphs = []) ⇒ Comment
Returns a new instance of Comment.
6 7 8 9 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb', line 6 def initialize(id = nil, paragraphs = []) @id = id @paragraphs = paragraphs end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb', line 4 def id @id end |
#paragraphs ⇒ Object
Returns the value of attribute paragraphs.
4 5 6 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb', line 4 def paragraphs @paragraphs end |
Class Method Details
.parse_list(parent: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb', line 11 def self.parse_list(parent: nil) comments = [] comments_filename = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/comments.xml" return [] unless File.exist?(comments_filename) doc = Nokogiri::XML(File.open(comments_filename)) doc.search('//w:comments').each do |document| document.xpath('w:comment').each do |comment_tag| comment = Comment.new(comment_tag.attribute('id').value) comment_tag.xpath('w:p').each_with_index do |p, index| comment.paragraphs << DocxParagraph.new.parse(p, index, parent: parent) end comments << comment.dup end end comments end |