Class: Kuromd::Journal::Note
- Includes:
- Fileable
- Defined in:
- lib/kuromd/journal/note.rb
Overview
Represents a note for a Journal process method will organize the note into it’s base folder
Constant Summary collapse
- NOTE_TYPE =
'Journal'
Instance Attribute Summary collapse
-
#base_folder ⇒ Object
Returns the value of attribute base_folder.
-
#file_date ⇒ Object
Returns the value of attribute file_date.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#params ⇒ Object
Returns the value of attribute params.
Attributes inherited from BaseNote
#config, #note_data, #note_type
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Note
constructor
A new instance of Note.
- #process ⇒ Object
- #valid? ⇒ Boolean
Methods included from Fileable
#create_journal_folder, #find_date_from_filename, #move
Methods inherited from BaseNote
assign_note_objs, categorize_by_note_objs, parse_markdown
Constructor Details
#initialize(params = {}) ⇒ Note
Returns a new instance of Note.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kuromd/journal/note.rb', line 19 def initialize(params = {}) super(params) @params = @config.params['journal'] @base_folder = @params['base_folder'] @file_path = params[:full_path] @file_date = @note_data['note_date'] @note_type = NOTE_TYPE Kuromd.logger.info "Journal note initialized: #{@note_data}, #{@params}" end |
Instance Attribute Details
#base_folder ⇒ Object
Returns the value of attribute base_folder.
15 16 17 |
# File 'lib/kuromd/journal/note.rb', line 15 def base_folder @base_folder end |
#file_date ⇒ Object
Returns the value of attribute file_date.
15 16 17 |
# File 'lib/kuromd/journal/note.rb', line 15 def file_date @file_date end |
#file_path ⇒ Object
Returns the value of attribute file_path.
15 16 17 |
# File 'lib/kuromd/journal/note.rb', line 15 def file_path @file_path end |
#params ⇒ Object
Returns the value of attribute params.
15 16 17 |
# File 'lib/kuromd/journal/note.rb', line 15 def params @params end |
Instance Method Details
#process ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kuromd/journal/note.rb', line 41 def process return unless valid? Kuromd.logger.info "Processing Journal Note: #{@note_data['title']}, #{@note_data['note_date']}" journal_folder = create_journal_folder(base_path: @base_folder, date: @file_date) new_filename = "#{@note_data['title']}#{::File.extname(@note_path)}" move({ dest_folder: journal_folder, source_path: @note_path, rename_to: new_filename }) end |
#valid? ⇒ Boolean
32 33 34 35 36 37 38 39 |
# File 'lib/kuromd/journal/note.rb', line 32 def valid? # needs a title and a note_date is_valid = false is_valid = !@note_data['title'].nil? && !@note_data['note_date'].nil? if category? Kuromd.logger.info "Journal Note object valid? #{is_valid}" is_valid end |