From 29fceb47a7ed33dd3fdad70c14129715c44ffa05 Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 25 Mar 2013 22:30:05 -0500 Subject: [PATCH 1/5] panda and tiger level --- db/seed.rb | 4 ++++ watchman.rb | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/db/seed.rb b/db/seed.rb index 3c028ff..c81efa5 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -3,5 +3,9 @@ Show.delete_all amc = Network.create(name: "AMC") nbc = Network.create(name: "NBC") +cbs = Network.create(name: "CBS") Show.create(name: "Mad Men", day_of_week: "Sunday", hour_of_day: 22, network: amc) Show.create(name: "Community", day_of_week: "Thursday", hour_of_day: 20, network: nbc) +Show.create(name: "60 Minutes", day_of_week: "Sunday", hour_of_day: 18, network: cbs) +Show.create(name: "Survivor", day_of_week: "Thursday", hour_of_day: 20, network: cbs) + diff --git a/watchman.rb b/watchman.rb index ebe9be4..7bd73d8 100644 --- a/watchman.rb +++ b/watchman.rb @@ -6,10 +6,18 @@ require "./db/seed" puts "There are #{Show.count} in the database" +puts "What day of the week would you like to watch a show?" +day_of_week = gets.chomp +count = 0 Network.all.each do |network| - puts "Shows airing on #{network}" network.shows.each do |show| - puts show - end + if show.day_of_week == day_of_week + puts "#{show} on #{network}" + count = count + 1 + end + end +end +if count == 0 + puts "no shows air on #{day_of_week}" end From 9bc7be7d726ecb4431d531fda2b1b66657957e7e Mon Sep 17 00:00:00 2001 From: dharini Date: Tue, 26 Mar 2013 00:40:20 -0500 Subject: [PATCH 2/5] initial work on eagle assignment --- db/migrate/201303251230_create_recipes.rb | 8 ++++++++ db/seed.rb | 6 ++++++ models/recipe.rb | 8 ++++++++ watchman.rb | 12 ++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 db/migrate/201303251230_create_recipes.rb create mode 100644 models/recipe.rb diff --git a/db/migrate/201303251230_create_recipes.rb b/db/migrate/201303251230_create_recipes.rb new file mode 100644 index 0000000..7de04bc --- /dev/null +++ b/db/migrate/201303251230_create_recipes.rb @@ -0,0 +1,8 @@ +class CreateRecipes < ActiveRecord::Migration + def change + create_table :recipes do |t| + t.string :dish + t.string :ingredient + end + end +end diff --git a/db/seed.rb b/db/seed.rb index c81efa5..4ccc973 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -9,3 +9,9 @@ Show.create(name: "60 Minutes", day_of_week: "Sunday", hour_of_day: 18, network: cbs) Show.create(name: "Survivor", day_of_week: "Thursday", hour_of_day: 20, network: cbs) +Recipe.delete_all +Recipe.create(dish: "salsa", ingredient: "[tomatoes, jalapenos, cilantro, onions]") +Recipe.create(dish: "guacamole", ingredient: "[avocados, tomatoes, jalapeno, cilantro, onions, cumin]") +Recipe.create(dish: "lentil soup", ingredient: "[red lentils, onions, celery, tomatoes, herbs de provence]") +Recipe.create(dish: "bruschetta", ingredient: "[bread, tomatoes, basil, red onions, basalmic vinegar]") +Recipe.create(dish: "hummus", ingredient: "[chickpeas, tahini, garlic, olive oil]") diff --git a/models/recipe.rb b/models/recipe.rb new file mode 100644 index 0000000..f3563eb --- /dev/null +++ b/models/recipe.rb @@ -0,0 +1,8 @@ +class Recipe < ActiveRecord::Base + + validates_presence_of :dish + + def to_s + "#{dish} has the following ingredients #{ingredient} " + end +end diff --git a/watchman.rb b/watchman.rb index 7bd73d8..88e8946 100644 --- a/watchman.rb +++ b/watchman.rb @@ -21,3 +21,15 @@ if count == 0 puts "no shows air on #{day_of_week}" end + +puts "There are #{Recipe.count} recipes in the database" +Recipe.all.each do |recipe| + puts "#{recipe}" +end +puts "What would you like to make?" +dish = gets.chomp +Recipe.all.each do |recipe| + if recipe.dish == dish + puts "#{recipe}" + end +end From f58716c82b390b46231db0e85bb3063caf9483a8 Mon Sep 17 00:00:00 2001 From: dharini Date: Wed, 27 Mar 2013 00:20:24 -0500 Subject: [PATCH 3/5] complete eagle assignment --- db/migrate/201303251230_create_recipes.rb | 3 ++- db/seed.rb | 10 +++++----- models/recipe.rb | 2 +- watchman.rb | 15 ++++++++------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/db/migrate/201303251230_create_recipes.rb b/db/migrate/201303251230_create_recipes.rb index 7de04bc..81b226c 100644 --- a/db/migrate/201303251230_create_recipes.rb +++ b/db/migrate/201303251230_create_recipes.rb @@ -2,7 +2,8 @@ class CreateRecipes < ActiveRecord::Migration def change create_table :recipes do |t| t.string :dish - t.string :ingredient + t.string :ingredients + t.string :instructions end end end diff --git a/db/seed.rb b/db/seed.rb index 4ccc973..c5521e9 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -10,8 +10,8 @@ Show.create(name: "Survivor", day_of_week: "Thursday", hour_of_day: 20, network: cbs) Recipe.delete_all -Recipe.create(dish: "salsa", ingredient: "[tomatoes, jalapenos, cilantro, onions]") -Recipe.create(dish: "guacamole", ingredient: "[avocados, tomatoes, jalapeno, cilantro, onions, cumin]") -Recipe.create(dish: "lentil soup", ingredient: "[red lentils, onions, celery, tomatoes, herbs de provence]") -Recipe.create(dish: "bruschetta", ingredient: "[bread, tomatoes, basil, red onions, basalmic vinegar]") -Recipe.create(dish: "hummus", ingredient: "[chickpeas, tahini, garlic, olive oil]") +Recipe.create(dish: "salsa", ingredients: "[tomatoes, jalapenos, cilantro, onions]", instructions: "chop and mix all ingredients together; season to taste") +Recipe.create(dish: "guacamole", ingredients: "[avocados, tomatoes, jalapeno, cilantro, onions, cumin]", instructions: "mash avocados; dice onions and tomatoes; mix all ingredients together; season to taste") +Recipe.create(dish: "lentil soup", ingredients: "[red lentils, onions, celery, tomatoes, herbs de provence]", instructions: "saute diced onions and celery in olive oil for 5 min; add red lentils, water, tomatoes, and spices; cook for 20 minutes") +Recipe.create(dish: "bruschetta", ingredients: "[bread, tomatoes, basil, red onions, basalmic vinegar]", instructions: "chop tomatoes, basil, red onions; add basalmic vinegar to mixture; serve with toasted bread") +Recipe.create(dish: "hummus", ingredients: "[chickpeas, tahini, garlic, olive oil]", instructions: "put all ingredients in blender and blend until it reaches smoot texture") diff --git a/models/recipe.rb b/models/recipe.rb index f3563eb..a52882d 100644 --- a/models/recipe.rb +++ b/models/recipe.rb @@ -3,6 +3,6 @@ class Recipe < ActiveRecord::Base validates_presence_of :dish def to_s - "#{dish} has the following ingredients #{ingredient} " + "#{dish} has the following ingredients #{ingredients} " end end diff --git a/watchman.rb b/watchman.rb index 88e8946..c6e5bf1 100644 --- a/watchman.rb +++ b/watchman.rb @@ -9,27 +9,28 @@ puts "What day of the week would you like to watch a show?" day_of_week = gets.chomp -count = 0 +show_in_entered_day_of_week = false Network.all.each do |network| network.shows.each do |show| if show.day_of_week == day_of_week puts "#{show} on #{network}" - count = count + 1 + show_in_entered_day_of_week = true end end end -if count == 0 - puts "no shows air on #{day_of_week}" -end +puts "no shows air on #{day_of_week}" unless show_in_entered_day_of_week -puts "There are #{Recipe.count} recipes in the database" +puts "These are the all the dishes in the database :" Recipe.all.each do |recipe| puts "#{recipe}" end puts "What would you like to make?" dish = gets.chomp +recipe_exists = false Recipe.all.each do |recipe| if recipe.dish == dish - puts "#{recipe}" + puts "#{recipe.instructions}" + recipe_exists = true end end +puts "Sorry, #{dish} does not exist in the database" unless recipe_exists From 2f2f85b0c57f328d79cbb38ac7cc93546b99ce30 Mon Sep 17 00:00:00 2001 From: dharini Date: Wed, 27 Mar 2013 20:37:50 -0500 Subject: [PATCH 4/5] correct spelling of word smooth --- db/seed.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seed.rb b/db/seed.rb index c5521e9..5521be7 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -14,4 +14,4 @@ Recipe.create(dish: "guacamole", ingredients: "[avocados, tomatoes, jalapeno, cilantro, onions, cumin]", instructions: "mash avocados; dice onions and tomatoes; mix all ingredients together; season to taste") Recipe.create(dish: "lentil soup", ingredients: "[red lentils, onions, celery, tomatoes, herbs de provence]", instructions: "saute diced onions and celery in olive oil for 5 min; add red lentils, water, tomatoes, and spices; cook for 20 minutes") Recipe.create(dish: "bruschetta", ingredients: "[bread, tomatoes, basil, red onions, basalmic vinegar]", instructions: "chop tomatoes, basil, red onions; add basalmic vinegar to mixture; serve with toasted bread") -Recipe.create(dish: "hummus", ingredients: "[chickpeas, tahini, garlic, olive oil]", instructions: "put all ingredients in blender and blend until it reaches smoot texture") +Recipe.create(dish: "hummus", ingredients: "[chickpeas, tahini, garlic, olive oil]", instructions: "put all ingredients in blender and blend until it reaches smooth texture") From cf5e2184cf8401997cfc65affad32fdf27b1dbc8 Mon Sep 17 00:00:00 2001 From: dharini Date: Wed, 27 Mar 2013 20:40:31 -0500 Subject: [PATCH 5/5] add a couple extra puts stmts --- watchman.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/watchman.rb b/watchman.rb index c6e5bf1..54c395e 100644 --- a/watchman.rb +++ b/watchman.rb @@ -19,6 +19,8 @@ end end puts "no shows air on #{day_of_week}" unless show_in_entered_day_of_week +puts "\n\n\n\n" + puts "These are the all the dishes in the database :" Recipe.all.each do |recipe| @@ -29,6 +31,7 @@ recipe_exists = false Recipe.all.each do |recipe| if recipe.dish == dish + puts "This is how you make #{dish} :" puts "#{recipe.instructions}" recipe_exists = true end