class NoteDeleter
Public Class Methods
new(notebook, title, notebook_path, workspace_path)
click to toggle source
# File lib/notes_cli/services/note_deleter.rb, line 6 def initialize(notebook, title, notebook_path, workspace_path) @notebook = notebook @title = title.join('_') @notebook_path = notebook_path @workspace_path = workspace_path end
Public Instance Methods
call()
click to toggle source
# File lib/notes_cli/services/note_deleter.rb, line 13 def call handle_errors delete_note notify end
Private Instance Methods
delete_note()
click to toggle source
# File lib/notes_cli/services/note_deleter.rb, line 27 def delete_note FileUtils.cd(@notebook_path) FileUtils.rm("#{@title}.md") FileUtils.cd(@workspace_path) end
handle_errors()
click to toggle source
# File lib/notes_cli/services/note_deleter.rb, line 21 def handle_errors raise ArgumentError, 'no notebook specified' if !@notebook || @notebook.empty? raise ArgumentError, 'no note title specified' if !@title || @title.empty? raise ArgumentError, 'notebook does not exist' unless notebook_exists?(@notebook) end
notify()
click to toggle source
# File lib/notes_cli/services/note_deleter.rb, line 33 def notify puts current_workspace.to_s puts '----------------' puts "Deleted '#{@title}' from your #{@notebook} notebook" end