Class: RhetButler::SlideTraverser

Inherits:
Object
  • Object
show all
Defined in:
lib/rhet-butler/slide-traverser.rb

Direct Known Subclasses

FilterResolver, IncludeProcessor, SlideRendering

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSlideTraverser

Returns a new instance of SlideTraverser.



5
6
7
8
# File 'lib/rhet-butler/slide-traverser.rb', line 5

def initialize
  @iter_stack = []
  @target_stack = []
end

Instance Attribute Details

#iter_stackObject (readonly)

Returns the value of attribute iter_stack.



10
11
12
# File 'lib/rhet-butler/slide-traverser.rb', line 10

def iter_stack
  @iter_stack
end

#target_stackObject (readonly)

Returns the value of attribute target_stack.



10
11
12
# File 'lib/rhet-butler/slide-traverser.rb', line 10

def target_stack
  @target_stack
end

Instance Method Details

#ascendObject



16
17
18
19
# File 'lib/rhet-butler/slide-traverser.rb', line 16

def ascend
  target_stack.pop
  iter_stack.pop
end

#descend(source, dest) ⇒ Object



21
22
23
24
# File 'lib/rhet-butler/slide-traverser.rb', line 21

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

#on_group(group) ⇒ Object



12
13
14
# File 'lib/rhet-butler/slide-traverser.rb', line 12

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

#traverseObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rhet-butler/slide-traverser.rb', line 26

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