diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..78d2e82 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..793e898 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/recipe-hash.iml b/.idea/recipe-hash.iml new file mode 100644 index 0000000..8f7472a --- /dev/null +++ b/.idea/recipe-hash.iml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..c80f219 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/advanced_train.rb b/advanced_train.rb new file mode 100644 index 0000000..20876fa --- /dev/null +++ b/advanced_train.rb @@ -0,0 +1,26 @@ +itinerary = %w'Vancouver Calgary Edmonton Winnipeg Toronto' +train = {} +train[:engines] = 1 +train[:cars] = 20 +train[:caboose] = "Great Western Trail" +train[:cities] = itinerary +train[:current_city] = "Edmonton" + +Passenger = Struct.new(:name, :train) +passenger = Passenger.new( "Simon Jones", train) + +puts "Passenger: #{passenger.name}" + +puts "\nTrain details" +passenger.train.each do |key, value| + if key == :cities + puts "\nItinerary" + value.each do |city| + print " * #{city}" + print " << CURRENT CITY" if city == passenger.train[:current_city] + puts "\n" + end + else + puts " -- #{key}: #{value}" if key != :current_city + end +end \ No newline at end of file diff --git a/recipe.rb b/recipe.rb index d4b2000..773e836 100644 --- a/recipe.rb +++ b/recipe.rb @@ -1,17 +1,15 @@ -ingredients = {} -ingredients[:avocados] = 4 -ingredients[:jalapenos] = 2 +train = {} +train[:engines] = 1 +train[:cars] = 20 +train[:caboose] = "Great Western Trail" +train[:city] = "Edmonton" -Recipe = Struct.new(:ingredients, :method) +Passenger = Struct.new(:name, :train) +passenger = Passenger.new( "Simon Jones", train) -recipe = Recipe.new( {avacados: 4, jalapenos: 2}, ["Peel / Slice Avocados", "Chop jalapenos into small dice"]) +puts "Passenger: #{passenger.name}" -puts "ingredients" -recipe.ingredients.each do |key, value| - puts "* #{key}: #{value}" +puts "\nTrain details" +passenger.train.each do |key, value| + puts " -- #{key}: #{value}" end - -puts "\nMethod" -recipe.method.each_with_index do |step, index| - puts "#{index+1}. #{step}" -end \ No newline at end of file