Class: Menu::AdapterMenu
Overview
menu class to select the storage adapter that should be used
Instance Attribute Summary collapse
-
#filename ⇒ String
readonly
private
The storage path.
Attributes inherited from Base
#menu_description, #menu_items
Instance Method Summary collapse
-
#define_menu_items ⇒ Object
private
method to define all printable menu items.
-
#determine_action(input) ⇒ Boolean
private
method to process the provided input.
-
#initialize(filename) ⇒ AdapterMenu
constructor
initialization.
-
#set_data_handler(data_handler) ⇒ Object
private
method to set the selected data handler @param data_handler the select storage handler.
Methods inherited from Base
#add_menu_item, #get_entry, #handle_wrong_option, #print_menu
Constructor Details
#initialize(filename) ⇒ AdapterMenu
initialization
7 8 9 10 11 |
# File 'lib/menu/adapter_menu.rb', line 7 def initialize(filename) super @menu_description = "\nSelect database adapter:" @filename = filename end |
Instance Attribute Details
#filename ⇒ String (readonly, private)
Returns the storage path.
16 17 18 |
# File 'lib/menu/adapter_menu.rb', line 16 def filename @filename end |
Instance Method Details
#define_menu_items ⇒ Object (private)
method to define all printable menu items
19 20 21 22 |
# File 'lib/menu/adapter_menu.rb', line 19 def ("File storage.", 1) ("Sqlite3.", 2) end |
#determine_action(input) ⇒ Boolean (private)
method to process the provided input
28 29 30 31 32 33 34 35 36 |
# File 'lib/menu/adapter_menu.rb', line 28 def determine_action(input) case (input.to_i) when 1 then set_data_handler(DataHandler::FileHandler.new(@filename)) when 2 then set_data_handler(DataHandler::SqliteHandler.new(@filename)) else handle_wrong_option end false end |
#set_data_handler(data_handler) ⇒ Object (private)
method to set the selected data handler @param data_handler the select storage handler
40 41 42 43 |
# File 'lib/menu/adapter_menu.rb', line 40 def set_data_handler(data_handler) Menu.initialize_datahandler(data_handler) nil end |