Class: Md2key::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/md2key/converter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Converter

Returns a new instance of Converter.



9
10
11
# File 'lib/md2key/converter.rb', line 9

def initialize(path)
  @markdown = Markdown.new(path)
end

Class Method Details

.convert_markdown(path) ⇒ Object



3
4
5
6
7
# File 'lib/md2key/converter.rb', line 3

def self.convert_markdown(path)
  abort "md2key: `#{path}` does not exist" unless File.exist?(path)

  self.new(path).generate_keynote!
end

Instance Method Details

#generate_keynote!Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/md2key/converter.rb', line 13

def generate_keynote!
  Keynote.activate
  @markdown.slides.each_with_index do |slide, index|
    if index == 0
      Keynote.update_master(slide.title, slide.lines.join('\n'))
      next
    end
    Keynote.create_slide(slide.title, slide.lines.join('\n'))
  end
  Keynote.delete_template_slide
end