Class: Scarlet::Slideshow
- Inherits:
-
Object
- Object
- Scarlet::Slideshow
- Defined in:
- lib/scarlet/slideshow.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#slides ⇒ Object
readonly
Returns the value of attribute slides.
Instance Method Summary collapse
-
#initialize(enumerable, options = {}) ⇒ Slideshow
constructor
A new instance of Slideshow.
- #render ⇒ Object
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 = formatter = [:format].nil? ? Scarlet::Formatter.default : Scarlet::Formatter.for([:format]) @slides = slice(enumerable) @slides.each { || .format!(formatter) } end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/scarlet/slideshow.rb', line 3 def @options end |
#slides ⇒ Object (readonly)
Returns the value of attribute slides.
3 4 5 |
# File 'lib/scarlet/slideshow.rb', line 3 def @slides end |
Instance Method Details
#render ⇒ Object
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([:template] || Scarlet::Formatters::HTML.default_template) ERB.new(template).result(binding) when :latex template = File.read([:template] || Scarlet::Formatters::LATEX.default_template) ERB.new(template).result(binding) when :pdf template = File.read([:template] || Scarlet::Formatters::PDF.default_template) Scarlet::Formatters::PDF.from_latex(ERB.new(template).result(binding)) else raise "Format not supported." end end |