Class: OoxmlParser::CommentAuthors
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::CommentAuthors
- Defined in:
- lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
Overview
Class for parsing ‘commentAuthors.xml` file
Instance Attribute Summary collapse
-
#list ⇒ Array<CommentAuthor>
readonly
List of comment authors.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#author_by_id(id) ⇒ CommentAuthor
Author by id.
-
#initialize(parent: nil) ⇒ CommentAuthors
constructor
A new instance of CommentAuthors.
-
#parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/commentAuthors.xml") ⇒ CommentAuthors
Parse CommentAuthors 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(parent: nil) ⇒ CommentAuthors
Returns a new instance of CommentAuthors.
10 11 12 13 |
# File 'lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb', line 10 def initialize(parent: nil) @list = [] super end |
Instance Attribute Details
#list ⇒ Array<CommentAuthor> (readonly)
Returns list of comment authors.
8 9 10 |
# File 'lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb', line 8 def list @list end |
Instance Method Details
#author_by_id(id) ⇒ CommentAuthor
Returns author by id.
35 36 37 |
# File 'lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb', line 35 def (id) list.detect { || .id == id } end |
#parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/commentAuthors.xml") ⇒ CommentAuthors
Parse CommentAuthors object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb', line 18 def parse(file = "#{root_object.unpacked_folder}/#{root_object.root_subfolder}/commentAuthors.xml") return nil unless File.exist?(file) document = parse_xml(file) node = document.xpath('*').first node.xpath('*').each do |node_child| case node_child.name when 'cmAuthor' @list << CommentAuthor.new(parent: self).parse(node_child) end end self end |