Class: TP::SlideFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/tp/slide_factory.rb

Class Method Summary collapse

Class Method Details

.from_markdown(markdown) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tp/slide_factory.rb', line 3

def self.from_markdown(markdown)
  lines = markdown.lines.to_a

  return Slide::HeaderOnly.new markdown if lines.count < 3

  content = lines[2, lines.count - 2].join

  case content.lines.first
  when /^\*\s/
    Slide::Bulleted.new markdown
  when /^\`{3}/
    Slide::Code.new markdown
  else
    Slide::Paragraph.new markdown
  end
end