Class: Til::NoteDeleter
- Inherits:
-
Object
- Object
- Til::NoteDeleter
- Includes:
- Thor::Actions, Thor::Base
- Defined in:
- lib/til/note_deleter.rb
Instance Attribute Summary collapse
-
#note ⇒ Object
readonly
Returns the value of attribute note.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(note) ⇒ NoteDeleter
constructor
A new instance of NoteDeleter.
Constructor Details
#initialize(note) ⇒ NoteDeleter
Returns a new instance of NoteDeleter.
7 8 9 |
# File 'lib/til/note_deleter.rb', line 7 def initialize(note) @note = note end |
Instance Attribute Details
#note ⇒ Object (readonly)
Returns the value of attribute note.
5 6 7 |
# File 'lib/til/note_deleter.rb', line 5 def note @note end |
Instance Method Details
#delete ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/til/note_deleter.rb', line 11 def delete begin choice = ask("Really delete \"#{note.title.bold}\" (in #{note.subject.bold})? (y/n)") if (choice == "y") || (choice == "yes") File.delete(note.path) puts "\"#{note.title.bold}\" deleted.".green else puts "\"#{note.title.bold}\" not deleted.".red end rescue Interrupt warn "\nAborted!" abort end end |