Class: RhetButler::SlideTraverser
- Inherits:
-
Object
- Object
- RhetButler::SlideTraverser
show all
- Defined in:
- lib/rhet-butler/slide-traverser.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
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_stack ⇒ Object
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_stack ⇒ Object
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
#ascend ⇒ Object
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
|
#traverse ⇒ Object
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
|