Class: Zlide::Deck
- Inherits:
-
Object
- Object
- Zlide::Deck
- Defined in:
- lib/zlide/deck.rb
Instance Method Summary collapse
-
#initialize ⇒ Deck
constructor
A new instance of Deck.
- #slide(index) ⇒ Object
- #to_html ⇒ Object
- #to_pdf ⇒ Object
- #update_slide(index, content) ⇒ Object
Constructor Details
#initialize ⇒ Deck
Returns a new instance of Deck.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/zlide/deck.rb', line 8 def initialize files = Dir.glob('slides/*.md') = Array.new files.sort.each do |f| = File.read(f).split(/(^!SLIDE.*$)/)[1..-1].each_slice(2).map(&:join) .each do || << {:file => f, :content => } end end end |
Instance Method Details
#slide(index) ⇒ Object
19 20 21 |
# File 'lib/zlide/deck.rb', line 19 def (index) [index][:content] end |
#to_html ⇒ Object
31 32 33 34 35 36 |
# File 'lib/zlide/deck.rb', line 31 def to_html = markdown_parser(Zlide::Redcarpet::Renderers::HTML).render(full_markdown) layout = File.read(File.join(File.dirname(__FILE__), "layouts", "deckjs.haml")) layout_renderer = Haml::Engine.new(layout) layout_renderer.render { } end |
#to_pdf ⇒ Object
38 39 40 41 42 |
# File 'lib/zlide/deck.rb', line 38 def to_pdf pdf = Zlide::Redcarpet::Renderers::PDF.new markdown_parser(pdf).render(full_markdown) pdf.write_file end |
#update_slide(index, content) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/zlide/deck.rb', line 23 def (index, content) [index][:content] = content file = [index][:file] = .select{|s| s[:file] == file}.map{|s| s[:content]} File.open("#{file}.tmp", "w") {|f| f.write(.join)} File.rename("#{file}.tmp", file) end |