Class: RecipeInspiration::CLI
- Inherits:
-
Object
- Object
- RecipeInspiration::CLI
- Defined in:
- lib/CLI_project/cli.rb
Instance Method Summary collapse
- #goodbye ⇒ Object
- #list_courses ⇒ Object
- #list_recipes(selected_course) ⇒ Object
- #menu ⇒ Object
- #menu_user_input ⇒ Object
- #recipe_details(selected_recipe) ⇒ Object
- #recipe_next_steps ⇒ Object
- #select_course(course_arr) ⇒ Object
- #select_recipe(recipe_arr) ⇒ Object
- #start ⇒ Object
Instance Method Details
#goodbye ⇒ Object
170 171 172 173 |
# File 'lib/CLI_project/cli.rb', line 170 def goodbye puts "\t Thank you for using the Meal Finder CLI. See you next time!" exit end |
#list_courses ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/CLI_project/cli.rb', line 42 def list_courses course_arr = RecipeInspiration::Course.all puts "\t \t Here are the courses that we have available. \t To choose a course, type in the corresponding number below to get a list of recipe suggestions. \t Or simply type 'exit' to exit the program \t" puts course_arr.map.with_index {|meal,index| "\t#{index+1}. #{meal.name}"} select_course(course_arr) end |
#list_recipes(selected_course) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/CLI_project/cli.rb', line 87 def list_recipes(selected_course) recipe_arr = RecipeInspiration::Recipes.all puts recipe_arr.map.with_index {|recipe, i| "#{i+1}. #{recipe.name}"} select_recipe(recipe_arr) end |
#menu ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/CLI_project/cli.rb', line 16 def puts "\t If you are looking for inspirations for your next meal then you've come to the right place. \t To see what courses we have available, simply type 'list courses' \t To exit the program, simply type 'exit'" end |
#menu_user_input ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/CLI_project/cli.rb', line 26 def input = gets.chomp if input.downcase == "list courses" RecipeInspiration::Course.list_course_names list_courses elsif input.downcase == "exit" goodbye else puts "\t Sorry I did not recognise that..." end end |
#recipe_details(selected_recipe) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/CLI_project/cli.rb', line 124 def recipe_details(selected_recipe) RecipeInspiration::Recipes.recipe_details(selected_recipe) puts "\t Not quite what you are looking for? \t Type 'list recipes' to go back to list of recipes from the same Course and choose a different dish\n\t \t To go back to the main menu, simply type 'list courses' \t To exit the program, type 'exit'" recipe_next_steps end |
#recipe_next_steps ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/CLI_project/cli.rb', line 137 def recipe_next_steps input = gets.chomp if input.downcase == "list recipes" recipe_arr = RecipeInspiration::Recipes.all puts recipe_arr.map.with_index {|recipe, i| "#{i+1}. #{recipe.name}"} select_recipe(recipe_arr) elsif input.downcase == "list courses" RecipeInspiration::Recipes.all.clear list_courses elsif input.downcase == "exit" goodbye else puts "\t Sorry I did not recognise that... \t Type 'list recipes' to go back to list of recipes from the same Course and choose a different dish\n\t \t To go back to the main menu, simply type 'list courses' \t To exit the program, type 'exit'" recipe_next_steps end end |
#select_course(course_arr) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/CLI_project/cli.rb', line 61 def select_course(course_arr) input = gets.chomp if input.downcase == "exit" goodbye elsif input.to_i > 0 && input.to_i < 23 selected_course = course_arr[input.to_i-1] puts "\t Great! Here are some ideas for you to make for #{selected_course.name}. Please type in the number of the dish you would like to \t find out more about or simply type in 'list courses' to go back to the main menu and choose a different course\t" else puts "\t Sorry, I did not recognise that..." list_courses end RecipeInspiration::Recipes.list_recipe_names(selected_course) list_recipes(selected_course) end |
#select_recipe(recipe_arr) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/CLI_project/cli.rb', line 98 def select_recipe(recipe_arr) input = gets.chomp if input.downcase == "list courses" RecipeInspiration::Recipes.all.clear list_courses elsif input.downcase == "exit" goodbye elsif input.to_i > 0 && input.to_i < 16 selected_recipe = recipe_arr[input.to_i-1] recipe_details(selected_recipe) else puts "\t Sorry, I did not recognise that. \t Please type in the number of the dish that you are looking for \t or 'list courses' to see the courses again or 'exit' to exit the program" select_recipe(recipe_arr) end end |
#start ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/CLI_project/cli.rb', line 7 def start puts " -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" puts " | |" puts " | Hello and welcome to the Meal Finder CLI. |" puts " | |" puts " -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" end |