Class: Menu::Scheduled
Overview
MenuConfig handlers
Instance Method Summary collapse
-
#add_scheduled ⇒ Object
Add scheduled issue.
- #create_input_map ⇒ Object
- #create_procs_map ⇒ Object
-
#list_scheduled ⇒ Object
List scheduled issues.
-
#remove_scheduled ⇒ Object
Remove scheduled issue.
Methods inherited from Base
#initialize, #run_default, #run_selected_command
Constructor Details
This class inherits a constructor from Menu::Base
Instance Method Details
#add_scheduled ⇒ Object
Add scheduled issue.
43 44 45 46 47 48 |
# File 'lib/menu/scheduled.rb', line 43 def add_scheduled Database.prepare_database ScheduledIssuesManager.new.add_scheduled([:add], [:repeat], [:date], [:start_time], [:duration]) end |
#create_input_map ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/menu/scheduled.rb', line 34 def create_input_map { add: [:add], remove: [:remove], list: [:list] } end |
#create_procs_map ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/menu/scheduled.rb', line 26 def create_procs_map { add: proc { add_scheduled }, remove: proc { remove_scheduled }, list: proc { list_scheduled } } end |
#list_scheduled ⇒ Object
List scheduled issues.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/menu/scheduled.rb', line 62 def list_scheduled Database.prepare_database rows = ScheduledIssuesManager.new.all_issues.map { |i| list_row_attributes(i) } table = Terminal::Table.new headings: list_headings, rows: rows if rows.count.positive? puts table else Utilities.log("Scheduled list is empty.") end end |
#remove_scheduled ⇒ Object
Remove scheduled issue.
51 52 53 54 55 56 57 58 59 |
# File 'lib/menu/scheduled.rb', line 51 def remove_scheduled Database.prepare_database deleted_count = ScheduledIssuesManager.new.remove_scheduled([:remove], [:date], [:repeat]) if deleted_count.positive? Utilities.log("#{deleted_count} #{Utilities.pluralize(deleted_count, 'issue', 'issues')} deleted.") else Utilities.log("No issues found with the given options.", { type: :error }) end end |