-
-
Save dpickett/0df618958791feb18249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MEATS = [ | |
'steak', | |
'roast beef' | |
] | |
FRUITS = [ | |
'apple', | |
'orange', | |
'grapes' | |
] | |
VEGETABLES = [ | |
'carrots', | |
'corn', | |
'squash' | |
] | |
class Food | |
def initialize(food_as_string) | |
@food_string = food_as_string | |
end | |
def meat? | |
MEATS.include?(@food_string) | |
end | |
def fruit? | |
FRUITS.include?(@food_string) | |
end | |
def vegetable? | |
VEGETABLES.include?(@food_string) | |
end | |
def food_group | |
if meat? | |
"it's a meat" | |
elsif fruit? | |
"it's a fruit" | |
elsif vegetable? | |
"it's a vegetable" | |
else | |
"We couldn't identify the food" | |
end | |
end | |
end | |
puts "What's for dinner?" | |
food = Food.new(gets.chomp) | |
puts food.food_group |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment