Sha256: d2dd39c5cb27e6d76bf5f1695c8c8d662255eeb5f3fa8eab5f540075181c1144

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require_relative 'time_node/common_timing'
require_relative 'animation_effect/animation_effect'
require_relative 'set_time_node/set_time_node'
module OoxmlParser
  # Class for parsing TimeNode tags
  class TimeNode < OOXMLDocumentObject
    attr_accessor :type, :common_time_node, :previous_conditions_list, :next_conditions_list

    def initialize(type = nil, parent: nil)
      @type = type
      @previous_conditions_list = []
      @next_conditions_list = []
      @parent = parent
    end

    # Parse TimeNode
    # @param node [Nokogiri::XML::Element] node to parse
    # @return [TimeNode] value of SheetFormatProperties
    def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'cTn'
          @common_time_node = CommonTiming.new(parent: self).parse(node_child)
        when 'prevCondLst'
          @previous_conditions_list = ConditionList.new(parent: self).parse(node_child)
        end
      end
      self
    end

    def self.parse_list(timing_list_node)
      timings = []
      timing_list_node.xpath('*').each do |time_node|
        case time_node.name
        when 'par'
          timings << TimeNode.new(:parallel, parent: timings).parse(time_node)
        when 'seq'
          timings << TimeNode.new(:sequence, parent: timings).parse(time_node)
        when 'anim'
          timings << TimeNode.new(:animate, parent: timings).parse(time_node)
        when 'set'
          timings << SetTimeNode.new(parent: timings).parse(time_node)
        when 'animEffect'
          timings << AnimationEffect.new(parent: timings).parse(time_node)
        when 'video'
          timings << :video
        when 'audio'
          timings << TimeNode.new(:audio, parent: timings).parse(time_node)
        end
      end
      timings
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ooxml_parser-0.6.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb
ooxml_parser-0.5.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb
ooxml_parser-0.5.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb