Class: RhetButler::IncludeProcessor

Inherits:
SlideTraverser show all
Defined in:
lib/rhet-butler/include-processor.rb

Defined Under Namespace

Classes: Collector

Instance Attribute Summary collapse

Attributes inherited from SlideTraverser

#iter_stack, #target_stack

Instance Method Summary collapse

Methods inherited from SlideTraverser

#traverse

Constructor Details

#initialize(loader) ⇒ IncludeProcessor

Returns a new instance of IncludeProcessor.



7
8
9
10
# File 'lib/rhet-butler/include-processor.rb', line 7

def initialize(loader)
  @loader = loader
  super()
end

Instance Attribute Details

#root_groupObject

Returns the value of attribute root_group.



5
6
7
# File 'lib/rhet-butler/include-processor.rb', line 5

def root_group
  @root_group
end

Instance Method Details

#ascendObject



31
32
33
34
35
36
37
# File 'lib/rhet-butler/include-processor.rb', line 31

def ascend
  target = target_stack.pop
  unless target == target_stack.last
    target.group.slides = target.slides
  end
  iter_stack.pop
end

#current_loaderObject



12
13
14
15
16
17
18
# File 'lib/rhet-butler/include-processor.rb', line 12

def current_loader
  if target_stack.empty?
    return @loader
  else
    return target_stack.last.loader
  end
end

#descend(source, dest) ⇒ Object



24
25
26
27
28
29
# File 'lib/rhet-butler/include-processor.rb', line 24

def descend(source, dest)
  unless Collector === dest
    dest = Collector.new(dest, [], current_loader)
  end
  super(source, dest)
end

#on_group(group) ⇒ Object



50
51
52
53
# File 'lib/rhet-butler/include-processor.rb', line 50

def on_group(group)
  target_stack.last.slides << group
  super
end

#on_include(includer) ⇒ Object



39
40
41
42
43
44
# File 'lib/rhet-butler/include-processor.rb', line 39

def on_include(includer)
  loader = includer.load(current_loader)
  collector = target_stack.last.dup
  collector.loader = loader
  descend(includer, collector)
end

#on_slide(slide) ⇒ Object



46
47
48
# File 'lib/rhet-butler/include-processor.rb', line 46

def on_slide(slide)
  target_stack.last.slides << slide
end

#setupObject



20
21
22
# File 'lib/rhet-butler/include-processor.rb', line 20

def setup
  descend(@root_group, @root_group)
end