Sha256: 5b6fb0efcb97cf0519cb44543e4ad9352b5b0d601c087ccaad47359eb8737f63

Contents?: true

Size: 801 Bytes

Versions: 8

Compression:

Stored size: 801 Bytes

Contents

require 'rhet-butler/yaml-schema'

module RhetButler
  class SlideTraverser
    def initialize
      @iter_stack = []
      @target_stack = []
    end

    attr_reader :iter_stack, :target_stack

    def on_group(group)
      descend(group, group)
    end

    def ascend
      target_stack.pop
      iter_stack.pop
    end

    def descend(source, dest)
      iter_stack.push source.each
      target_stack.push dest
    end

    def traverse
      setup
      until iter_stack.empty?
        begin
          item = iter_stack.last.next
          case item
          when Slide
            on_slide(item)
          when Includer
            on_include(item)
          else
            on_group(item)
          end
        rescue StopIteration
          ascend
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rhet-butler-0.14.1 lib/rhet-butler/slide-traverser.rb
rhet-butler-0.14.0 lib/rhet-butler/slide-traverser.rb
rhet-butler-0.13.0 lib/rhet-butler/slide-traverser.rb
rhet-butler-0.12.1 lib/rhet-butler/slide-traverser.rb
rhet-butler-0.11.1 lib/rhet-butler/slide-traverser.rb
rhet-butler-0.11.0 lib/rhet-butler/slide-traverser.rb
rhet-butler-0.10.0 lib/rhet-butler/slide-traverser.rb
rhet-butler-0.9.0 lib/rhet-butler/slide-traverser.rb