Skip to content

Instantly share code, notes, and snippets.

@dbc-challenges
Last active March 31, 2023 01:10
Show Gist options
  • Save dbc-challenges/3247ba09cef79aa969a7 to your computer and use it in GitHub Desktop.
Save dbc-challenges/3247ba09cef79aa969a7 to your computer and use it in GitHub Desktop.
Bernie's Bistro
class Recipe
# I need to finish this before I give Bernie the program...
end
class Bistro
def initialize
@recipes = []
end
def load_recipes(filename)
# I need to finish this before I give Bernie the program...
# The CSV file looks like this:
# "id", "name", "description", "ingredients", "directions"
end
def find_recipe_by_id(recipe_id)
recipes = []
@recipes.each do |recipe|
recipes << recipe if recipe.id == recipe_id
end
raise "Can't find a recipe with an id of #{recipe_id.inspect}" unless recipe
recipes
end
end
if ARGV.any?
# I wonder if I could clean this up...
bistro = Bistro.new
bistro.load_recipes("recipes.csv")
if ARGV[0] == "list"
raise "TODO: implement listing of recipes"
elsif ARGV[0] == "display"
puts bistro.find_recipe_by_id(ARGV[1])
end
end
require_relative('bistro')
# Your driver code here
id name description ingredients directions
1 Kale Burger Combining the taste of cow with the nutrition of kale! Kale, Cow Preheat oven to 500 degrees, put in a cow. Wait 10 minutes. Put in some kale. Take out cow and kale. Put on bun. Serve HOT!
2 Poodle Cake (For your puppy!) Poople cakes! Perfect for pet poodle! Kibble, Hot dogs Mix kibble with hot dog. Bake at 500 degrees for 25 minutes. DO NOT ADD CHOCOLATE
3 Peanut Butter Coffee Brownie Just looking has caused people to gain 10 pounds! Chocolate, Peanut Butter, Espresso, Cream Cheese Chew the espresso beans to a pulp, spit them into the bowl. Now mix in the chocolate, cream cheese, and peanut butter. Bake at 450 for 45 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment