Skip to content

Instantly share code, notes, and snippets.

@dpickett
Created March 13, 2014 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpickett/0df618958791feb18249 to your computer and use it in GitHub Desktop.
Save dpickett/0df618958791feb18249 to your computer and use it in GitHub Desktop.
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