diff --git a/recipe.rb b/recipe.rb index d4b2000..8e98504 100644 --- a/recipe.rb +++ b/recipe.rb @@ -1,17 +1,23 @@ -ingredients = {} -ingredients[:avocados] = 4 -ingredients[:jalapenos] = 2 - -Recipe = Struct.new(:ingredients, :method) +class Train < Struct.new(:current_city,:engines,:number_of_cars,:caboose) +end -recipe = Recipe.new( {avacados: 4, jalapenos: 2}, ["Peel / Slice Avocados", "Chop jalapenos into small dice"]) +train = Train.new("NYC",2,4,1) -puts "ingredients" -recipe.ingredients.each do |key, value| - puts "* #{key}: #{value}" +puts "-----------" +puts "TRAIN INFO" +puts "-----------" +train.members.each do |attribute| + puts "#{attribute.to_s.capitalize.gsub('_',' ')} - #{train.send(attribute)}" end -puts "\nMethod" -recipe.method.each_with_index do |step, index| - puts "#{index+1}. #{step}" -end \ No newline at end of file +# ^^^^ I know this isn't particularly pretty I just wanted to try it with one line! +# But, a more readable way: + +puts "-----------" +puts "TRAIN INFO" +puts "-----------" +puts "Current city - #{train.current_city} " +puts "Engines - #{train.engines} " +puts "Number of cars - #{train.number_of_cars}" +puts "Caboose - #{train.caboose} " + diff --git a/student.rb b/student.rb deleted file mode 100644 index db9157b..0000000 --- a/student.rb +++ /dev/null @@ -1,10 +0,0 @@ -Student = Struct.new(:first_name, :last_name, :grade) do - - def senior? - grade == 12 - end - - def to_s - "#{last_name}, #{first_name}" - end -end \ No newline at end of file