Class: MealSelector::MealSelector
- Inherits:
-
Object
- Object
- MealSelector::MealSelector
- Defined in:
- lib/meal_selector/meal_selector.rb
Overview
Menu for MealSelector
Instance Method Summary collapse
-
#initialize ⇒ MealSelector
constructor
Set up Frontend and Backend.
-
#menu ⇒ void
Main menu for Meal Selector.
Constructor Details
#initialize ⇒ MealSelector
Set up Frontend and Backend
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/meal_selector/meal_selector.rb', line 9 def initialize # Trys to load key from file begin @backend = Backend.new(ApiInterface.load) rescue RuntimeError @backend = nil end # Asks for api/key if file does not exist/bad format if @backend.nil? @backend = init_kv_dialog init_save_dialog end @frontend = Frontend.new end |
Instance Method Details
#menu ⇒ void
This method returns an undefined value.
Main menu for Meal Selector
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/meal_selector/meal_selector.rb', line 26 def quit = false until quit Frontend.clear puts 'Thank you for using Meal Selector.' puts 'Please select a number from the options below:' puts '`1` Search for meal by name' puts '`2` Show meals by a category' puts '`3` Search meals by a main ingrediant' puts '`4` Show a random meal' allowed_input = meal_second_half input = Frontend.user_input(4, *allowed_input) quit = (input) sleep 0.5 # delay clearing screen end end |