class DayoneToQuiver::API::DayoneJournalToQuiverNotebook

Attributes

result[R]

Public Class Methods

new(journal_file, options) click to toggle source
# File lib/dayone_to_quiver/api.rb, line 28
def initialize(journal_file, options)
  @input_file = journal_file
  @journal = ::DayoneToolbox::Journal.new(journal_file)
  @notebook = QuiverToolbox::Notebook.new do |n|
    n.name = options[:name]
    n.store_path = options[:output]
  end
  @result = ''
end

Public Instance Methods

exec() click to toggle source
# File lib/dayone_to_quiver/api.rb, line 39
def exec
  @notebook.store
  @journal.entries.each do |entry|
    entry_obj = ::DayoneToQuiver::DayoneEntry.new(entry)
    note = @notebook.build_note(entry_obj.to_quiver_hash)
    converter = ::DayoneToQuiver::Converter.new(entry_obj, note)

    @result << "#{converter.note.file_name_with_path}\n" if converter.store
  end
  self
end