Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions recipe.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
ingredients = {}
ingredients[:avocados] = 4
ingredients[:jalapenos] = 2

Recipe = Struct.new(:ingredients, :method)
Train = Struct.new(:city, :engines, :cars, :caboose) do
def info
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GREAT job with putting info as a method on train. 👍

"This train is going to #{city}, and it has #{engines} engines, #{cars} cars, and #{caboose} caboose."
end
end

recipe = Recipe.new( {avacados: 4, jalapenos: 2}, ["Peel / Slice Avocados", "Chop jalapenos into small dice"])
amtrack = Train.new("San Jose", 2, 8, 1)

puts "ingredients"
recipe.ingredients.each do |key, value|
puts "* #{key}: #{value}"
Passenger = Struct.new(:name, :train) do
def trip
"#{name} is riding the #{train} while on vacation."
end
end

puts "\nMethod"
recipe.method.each_with_index do |step, index|
puts "#{index+1}. #{step}"
end
first_passenger = Passenger.new("Sharon", "amtrack")
puts first_passenger.trip
puts amtrack.info
#amtrack.each_pair {|name, value| puts("About the train: #{name} => #{value}")}
#The above line is not necessary, but I thought it was cool:-)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally cool !