Module: Menu
- Included in:
- DiscreteMath
- Defined in:
- lib/modules/menus/menu.rb
Constant Summary collapse
- EXIT_MAIN_MENU_OPTIONS =
["3"]
Class Method Summary collapse
- .exit ⇒ Object
- .request_input_for_menu(menu_kind) ⇒ Object
- .show_choices_main_menu ⇒ Object
- .show_greeting ⇒ Object
- .show_main_menu ⇒ Object
Class Method Details
.exit ⇒ Object
12 13 14 15 |
# File 'lib/modules/menus/menu.rb', line 12 def self.exit puts "\nThank you for trying Discrete Math Demo" Kernel.exit(false) end |
.request_input_for_menu(menu_kind) ⇒ Object
17 18 19 20 21 |
# File 'lib/modules/menus/menu.rb', line 17 def self.() MenuHelpers.clear MenuHelpers.() puts 'Enter a number: ' end |
.show_choices_main_menu ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/modules/menus/menu.rb', line 35 def self. Menu.("main") user_input = "" while not EXIT_MAIN_MENU_OPTIONS.include? user_input user_input = gets.chomp case user_input when "1" . when "2" . when "3" Menu.exit else MenuHelpers.("main") Menu. end end end |
.show_greeting ⇒ Object
8 9 10 |
# File 'lib/modules/menus/menu.rb', line 8 def self.show_greeting puts "Welcome to Discrete Math Demo\nEnter a number to navigate" end |
.show_main_menu ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/modules/menus/menu.rb', line 23 def self. table = MenuHelpers.terminal_table do |t| t.title = Menu.show_greeting t.add_row [1, 'Demos'] t.add_row [2, 'Help'] t.add_row [3, 'Exit'] t.style = { all_separators: true } end puts table puts '' end |