Sha256: dad0c63300a9c45dd9f2e773083d9cf603c93138672b7a0102fe0ad42df9d340

Contents?: true

Size: 1.08 KB

Versions: 28

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require_relative 'comment_authors/comment_author'
module OoxmlParser
  # Class for parsing `commentAuthors.xml` file
  class CommentAuthors < OOXMLDocumentObject
    # @return [Array<CommentAuthor>] list of comment authors
    attr_reader :list

    def initialize(parent: nil)
      @list = []
      super
    end

    # Parse CommentAuthors object
    # @param file [Nokogiri::XML:Element] node to parse
    # @return [CommentAuthors] result of parsing
    def parse(file = "#{OOXMLDocumentObject.path_to_folder}/#{OOXMLDocumentObject.root_subfolder}/commentAuthors.xml")
      return nil unless File.exist?(file)

      document = parse_xml(File.open(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

    # @param id [Integer] id of author
    # @return [CommentAuthor] author by id
    def author_by_id(id)
      list.detect { |author| author.id == id }
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ooxml_parser-0.29.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.28.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.27.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.26.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.25.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.24.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.23.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.22.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.21.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.20.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.19.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.18.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.18.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.17.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.16.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.15.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.14.2 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.14.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb
ooxml_parser-0.14.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb