Class: Scarlet::Slideshow

Inherits:
Object
  • Object
show all
Defined in:
lib/scarlet/slideshow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enumerable, options = {}) ⇒ Slideshow

Returns a new instance of Slideshow.



5
6
7
8
9
10
# File 'lib/scarlet/slideshow.rb', line 5

def initialize(enumerable, options={})
  @options = options
  formatter = options[:format].nil? ? Scarlet::Formatter.default : Scarlet::Formatter.for(options[:format]) 
  @slides = slice(enumerable)
  @slides.each { |slide| slide.format!(formatter) }
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/scarlet/slideshow.rb', line 3

def options
  @options
end

#slidesObject (readonly)

Returns the value of attribute slides.



3
4
5
# File 'lib/scarlet/slideshow.rb', line 3

def slides
  @slides
end

Instance Method Details

#renderObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scarlet/slideshow.rb', line 12

def render
  case @options[:format]
  when :html
    template = File.read(options[:template] || Scarlet::Formatters::HTML.default_template)
    ERB.new(template).result(binding)
  when :latex
    template = File.read(options[:template] || Scarlet::Formatters::LATEX.default_template)
    ERB.new(template).result(binding)
  when :pdf
    template = File.read(options[:template] || Scarlet::Formatters::PDF.default_template)
    Scarlet::Formatters::PDF.from_latex(ERB.new(template).result(binding))
  else
    raise "Format not supported."
  end
end