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
34 changes: 23 additions & 11 deletions recipe.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
ingredients = {}
ingredients[:avocados] = 4
ingredients[:jalapenos] = 2
# Method(s) to prettify output format

Recipe = Struct.new(:ingredients, :method)
def prettify(obj)
Copy link
Member

Choose a reason for hiding this comment

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

Like this.

To stretch you, could you make the method turn number_of_cars into "Number Of Cars"?

obj.to_s.capitalize.gsub(/_/, ' ')
end

train = {}
train[:current_city] = "St. Louis"
train[:number_of_engines] = 3
train[:number_of_cars] = 10
train[:caboose] = true

Passenger = Struct.new(:passenger_information, :train)

recipe = Recipe.new( {avacados: 4, jalapenos: 2}, ["Peel / Slice Avocados", "Chop jalapenos into small dice"])
passenger = Passenger.new( {name: "Mike Vezzani", city_of_origin: "St. Louis",
travelling_to: "San Francisco"}, {current_city: "St. Louis",
number_of_engines: 3,
number_of_cars: 10,
caboose: true})

puts "ingredients"
recipe.ingredients.each do |key, value|
puts "* #{key}: #{value}"
puts "---- Passenger Information ----"
passenger.passenger_information.each do |k, v|
puts "#{prettify(k)}: #{v}"
end

puts "\nMethod"
recipe.method.each_with_index do |step, index|
puts "#{index+1}. #{step}"
puts "---- Train Information ----"
passenger.train.each do |k, v|
puts "#{prettify(k)}: #{v}"
end