Sha256: be7d402a9927fcf59254bd568c75c884b98b2ab71e292fa4eb8550fcb1d97db9

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 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 = "#{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

    # @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

11 entries across 11 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.37.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.36.1 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.36.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.35.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.34.2 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.34.1 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.34.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.33.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.32.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb
ooxml_parser-0.31.0 lib/ooxml_parser/pptx_parser/presentation/comment_authors.rb