Class: OoxmlParser::Comments
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Comments
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/comments.rb
Overview
Class for parsing ‘comments.xml` file
Instance Attribute Summary collapse
-
#comments_array ⇒ Array<Comment>
readonly
List of comments.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#[](key) ⇒ Comment
Accessor.
-
#initialize(params = {}) ⇒ Comments
constructor
A new instance of Comments.
-
#parse ⇒ Comments
Parse CommentsExtended object.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(params = {}) ⇒ Comments
Returns a new instance of Comments.
10 11 12 13 14 |
# File 'lib/ooxml_parser/docx_parser/document_structure/comments.rb', line 10 def initialize(params = {}) @comments_array = [] super(parent: params[:parent]) @file = params.fetch(:file, "#{root_object.unpacked_folder}word/comments.xml") end |
Instance Attribute Details
#comments_array ⇒ Array<Comment> (readonly)
Returns list of comments.
8 9 10 |
# File 'lib/ooxml_parser/docx_parser/document_structure/comments.rb', line 8 def comments_array @comments_array end |
Instance Method Details
#[](key) ⇒ Comment
Returns accessor.
17 18 19 |
# File 'lib/ooxml_parser/docx_parser/document_structure/comments.rb', line 17 def [](key) @comments_array[key] end |
#parse ⇒ Comments
Parse CommentsExtended object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ooxml_parser/docx_parser/document_structure/comments.rb', line 23 def parse return nil unless File.file?(@file) doc = parse_xml(@file) doc.xpath('w:comments/*').each do |node_child| case node_child.name when 'comment' @comments_array << Comment.new(parent: self).parse(node_child) end end self end |