Class: DayOne2MD::Converter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Converter

Returns a new instance of Converter.



5
6
7
# File 'lib/dayone2md/converter.rb', line 5

def initialize(opts={})
  @opts = opts
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



3
4
5
# File 'lib/dayone2md/converter.rb', line 3

def opts
  @opts
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/dayone2md/converter.rb', line 9

def run
  DayOneEntry.all(opts[:input]).each do |entry|
    MarkdownEntry.new(
      date:     entry.date,
      title:    entry.title,
      content:  entry.content,
      dir:      opts[:output]
    ).save
  end
end