Sha256: 645c94bdb9fc9dfb315cbbe5afd2a289b4e1ed1c6850e884756123511c924dae

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'rhet-butler/slide-renderer'
require 'rhet-butler/slide-traverser'
module RhetButler
  class SlideRendering < SlideTraverser
    attr_accessor :root_group, :file_set

    def setup
      descend(@root_group, @root_group)
    end

    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

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rhet-butler-0.14.1 lib/rhet-butler/slide-rendering.rb
rhet-butler-0.14.0 lib/rhet-butler/slide-rendering.rb
rhet-butler-0.13.0 lib/rhet-butler/slide-rendering.rb