Class: MyTodo::Todo
Overview
Todo tasks using thor gem
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #list ⇒ Object
- #note ⇒ Object
- #notes ⇒ Object
- #rm_note ⇒ Object
- #rm_tag ⇒ Object
- #search ⇒ Object
- #tag ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/my_todo.rb', line 42 def create begin say 'ToDo CREATED!' create_item() print_item rescue ActiveRecord::RecordInvalid => e say e. end end |
#delete ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/my_todo.rb', line 67 def delete begin item.destroy! say 'ToDo DESTROYED!' rescue StandardError => e say e. end end |
#list ⇒ Object
34 35 36 37 |
# File 'lib/my_todo.rb', line 34 def list say "ToDos FOUND: #{all_items.count}" print_list end |
#note ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/my_todo.rb', line 112 def note begin item.notes.create(body: [:body]) print_notes rescue StandardError => e say e. end end |
#notes ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/my_todo.rb', line 135 def notes begin print_notes rescue StandardError => e say e. end end |
#rm_note ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/my_todo.rb', line 124 def rm_note begin item.notes.where(id: [:noteid]).first.destroy! print_list item.reload rescue StandardError => e say e. end end |
#rm_tag ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/my_todo.rb', line 100 def rm_tag begin item..where(name: [:tag]).first.destroy! print_list item.reload rescue StandardError => e say e. end end |
#search ⇒ Object
78 79 80 81 82 83 |
# File 'lib/my_todo.rb', line 78 def search @items = Item.ransack(body_or_detailed_status_or_tags_name_or_notes_body_cont: [:text]).result say "ToDos FOUND: #{@items.count}" say "Search based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont" print_search_results end |
#tag ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/my_todo.rb', line 88 def tag begin item..create!(name: [:tag]) print_list item.reload rescue StandardError => e say e. end end |
#update ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/my_todo.rb', line 55 def update begin update_item() say 'ToDo UPDATED!' print_item rescue ActiveRecord::RecordInvalid => e say e. end end |