Class: DailyRecipe::CLI
- Inherits:
-
Object
- Object
- DailyRecipe::CLI
- Defined in:
- lib/daily_recipe/cli.rb
Overview
our CLI controller
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
5 6 7 8 9 |
# File 'lib/daily_recipe/cli.rb', line 5 def call puts "Here are today's Daily Recipes" list_recipes end |
#goodbye ⇒ Object
45 46 47 |
# File 'lib/daily_recipe/cli.rb', line 45 def goodbye puts "Please join us tomorrow for more amazing recipes!" end |
#list_recipes ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/daily_recipe/cli.rb', line 11 def list_recipes #will get recipes @recipes = DailyRecipe::Recipe.today puts " Recipe name Rating Cooking Time" @recipes.each.with_index(1) do |recipe, i| #There is a Recipe class with a #today method for today's recipes puts "#{i}. #{recipe.name} - #{recipe.rating} - #{recipe.cook_time}" end end |
#menu ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/daily_recipe/cli.rb', line 21 def input = nil while input != "exit" puts "Enter the number of the recipe you would like to explore." puts "Enter list to see the full list of recipes." puts "Type exit to exit" input = gets.strip.downcase if input.to_i > 0 and input.to_i <= @recipes.count the_recipe = @recipes[input.to_i-1] puts "#{the_recipe.name} - #{the_recipe.rating} - #{the_recipe.cook_time}" DailyRecipe::Recipe.scrape_full_recipe(the_recipe) elsif input == "list" list_recipes elsif input == "exit" goodbye else puts "Not sure what you are asking for, type list or exit." end end end |