Class: RhetButler::SlideRendering

Inherits:
SlideTraverser show all
Defined in:
lib/rhet-butler/slide-rendering.rb

Instance Attribute Summary collapse

Attributes inherited from SlideTraverser

#iter_stack, #target_stack

Instance Method Summary collapse

Methods inherited from SlideTraverser

#ascend, #descend, #initialize, #on_group, #traverse

Constructor Details

This class inherits a constructor from RhetButler::SlideTraverser

Instance Attribute Details

#file_setObject

Returns the value of attribute file_set.



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

def file_set
  @file_set
end

#root_groupObject

Returns the value of attribute root_group.



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

def root_group
  @root_group
end

Instance Method Details

#filter_text(content, filters) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rhet-butler/slide-rendering.rb', line 21

def filter_text(content, filters)
  case content
  when String
    filters.inject(content) do |text, filter|
      filter.process(text)
    end
  when Array
    content.map{|item| filter_text(item, filters)}.join("")
  when SlideContents
    filter_text(content.content(file_set), content.filters)
  else
    raise "Don't know how to filter slide content like #{content.inspect}"
  end
end

#on_slide(slide) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/rhet-butler/slide-rendering.rb', line 11

def on_slide(slide)
  slide.content = filter_text(slide.raw_content, slide.content_filters)
  slide.notes = filter_text(slide.raw_notes, slide.note_filters)
  raise "Slide content needs to be a string, was: #{slide.content.inspect}" unless String === slide.content
  raise "Slide notes needs to be a string, was: #{slide.notes.inspect}" unless String === slide.notes
rescue
  puts "While processing #{slide}:"
  raise
end

#setupObject



7
8
9
# File 'lib/rhet-butler/slide-rendering.rb', line 7

def setup
  descend(@root_group, @root_group)
end