Class: Menu::MainMenu
- Includes:
- Listenable
- Defined in:
- lib/menu/main_menu.rb
Overview
menu class that inherits Base to abstract the main menu
Instance Attribute Summary
Attributes inherited from Base
#menu_description, #menu_items
Instance Method Summary collapse
-
#define_menu_items ⇒ Object
private
implementation to define the items of the menu.
-
#determine_action(input) ⇒ Object
private
method to specify the actions to a given input.
-
#initialize ⇒ MainMenu
constructor
initialization.
-
#prepare_menu(menu) ⇒ Object
private
method to register the listener to a given menu and print its items.
Methods included from Listenable
#add_listener, #listeners, #notify_listeners, #remove_listener
Methods inherited from Base
#add_menu_item, #get_entry, #handle_wrong_option, #print_menu
Constructor Details
#initialize ⇒ MainMenu
initialization
11 12 13 14 |
# File 'lib/menu/main_menu.rb', line 11 def initialize super @menu_description = "Main menu. Select operation:" end |
Instance Method Details
#define_menu_items ⇒ Object (private)
implementation to define the items of the menu
19 20 21 22 23 24 |
# File 'lib/menu/main_menu.rb', line 19 def ("Create or change index.", 1) ("Print an index.", 2) ("Generate bar chart.", 3) ("Quit.", 4) end |
#determine_action(input) ⇒ Object (private)
method to specify the actions to a given input
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/menu/main_menu.rb', line 28 def determine_action(input) case (input.to_i) when 1 then (Menu::IndexOverviewMenu.new()) when 2 then (Menu::IndexOutputMenu.new()) when 3 then (Menu::DiagramMenu.new()) when 4 puts "Shutting down. Goodbye ...".yellow exit(0) end end |
#prepare_menu(menu) ⇒ Object (private)
method to register the listener to a given menu and print its items
41 42 43 44 |
# File 'lib/menu/main_menu.rb', line 41 def () .add_listener(:repo_listener, listeners[:repo_listener]) . end |