Created
October 1, 2013 07:46
-
-
Save ngpestelos/6775106 to your computer and use it in GitHub Desktop.
personal chef from Ruby in 100 Minutes (http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html)
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
class PersonalChef | |
def make_toast | |
puts "Making your toast!" | |
end | |
def make_milkshake | |
puts "Making your milkshake!" | |
end | |
def make_toast(color) | |
if color.nil? | |
puts "How am I supposed to make nothingness toast?" | |
else | |
puts "Making your toast #{color}" | |
end | |
end | |
def make_milkshake(flavor) | |
puts "Making your milkshake #{flavor}" | |
return self | |
end | |
def make_eggs(quantity) | |
quantity.times do | |
puts "Making an egg." | |
end | |
puts "I'm done" | |
return self | |
end | |
def gameplan(meals) | |
meals.each do |meal| | |
puts "We'll have #{meal}" | |
end | |
all_meals = meals.join(", ") | |
puts "In summary: #{all_meals}" | |
end | |
def inventory | |
produce = {apples: 3, oranges: 1, carrots: 12} | |
produce.each do |item, quantity| | |
puts "There are #{quantity} #{item} in the fridge" | |
end | |
end | |
def water_status(minutes) | |
if minutes < 7 | |
puts "The water is not boiling yet" | |
elsif minutes == 7 | |
puts "It's just barely boiling" | |
elsif minutes == 8 | |
puts "It's boiling" | |
else | |
puts "Hot!" | |
end | |
return self | |
end | |
def countdown(counter) | |
while counter > 0 | |
puts "The counter is #{counter}" | |
counter = counter - 1 | |
end | |
return self | |
end | |
end | |
class Butler | |
def open_front_door | |
puts "Opening your front door" | |
end | |
def open_door(name) | |
puts "Opening your #{name} door" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment