Class: Menu::DatabaseOption
Overview
This class holds the menu for query options regarding person and task query and the addition of people or tasks
Instance Attribute Summary
Attributes inherited from Base
#menu_description, #menu_items
Instance Method Summary collapse
-
#database_menu ⇒ Object
main entry point, this method gets the DataHandler from the MainMenu to work on the repository and to initiate the save operation.
-
#define_menu_items ⇒ Object
private
method to define all printable menu items.
-
#determine_action(input) ⇒ Boolean
private
method to process the provided input.
-
#initialize ⇒ DatabaseOption
constructor
initialization.
-
#save_and_exit ⇒ Object
private
method to save the current repository and exit the script.
Methods inherited from Base
#add_menu_item, #get_entry, #handle_wrong_option, #print_menu
Constructor Details
#initialize ⇒ DatabaseOption
initialization
8 9 10 11 |
# File 'lib/menu/database_option.rb', line 8 def initialize super @menu_description = "\nDatabase options" end |
Instance Method Details
#database_menu ⇒ Object
main entry point, this method gets the DataHandler from the MainMenu to work on the repository and to initiate the save operation
15 16 17 18 |
# File 'lib/menu/database_option.rb', line 15 def Query.initialize_repository(Menu.data_handler) end |
#define_menu_items ⇒ Object (private)
method to define all printable menu items
23 24 25 26 27 28 29 |
# File 'lib/menu/database_option.rb', line 23 def ("Add entity.", 1) ("Query entities.", 2) ("Query worktime.", 3) ("Save and exit.", 4) ("Abort and exit.", 5) end |
#determine_action(input) ⇒ Boolean (private)
method to process the provided input
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/menu/database_option.rb', line 35 def determine_action(input) case (input.to_i) when 1 then EntityAddition.new. when 2 then EntityQueries.new. when 3 then WorktimeQueries.new. when 4 then save_and_exit when 5 then Menu.exit_script else handle_wrong_option end return true end |
#save_and_exit ⇒ Object (private)
method to save the current repository and exit the script
49 50 51 52 53 54 55 56 |
# File 'lib/menu/database_option.rb', line 49 def save_and_exit begin Menu.data_handler.persist_data Menu.exit_script rescue IOError => e raise IOError, "Error while saving data: ".concat(e.).red end end |