Class: DayoneToQuiver::API::DayoneJournalToQuiverNotebook

Inherits:
Object
  • Object
show all
Defined in:
lib/dayone_to_quiver/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(journal_file, options) ⇒ DayoneJournalToQuiverNotebook

Returns a new instance of DayoneJournalToQuiverNotebook.



28
29
30
31
32
33
34
35
36
# 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

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



27
28
29
# File 'lib/dayone_to_quiver/api.rb', line 27

def result
  @result
end

Instance Method Details

#execObject



39
40
41
42
43
44
45
46
47
48
49
# 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