lib/bake_my_day/order_item.rb
def add_packs()	
		packages_for_this_item.each do |pack_units, pack_price|
			# If there are more remaining units than in this package, create a pack and see how many packs you need.
			if @remaining_units > pack_units
				Tracer.debug "remaining_units: " + @remaining_units.to_s + " pack_units: " + pack_units.to_s
				# How many packs of this package?
				num_of_packs = @remaining_units / pack_units
				@item_total += num_of_packs * pack_price
			
				pack = Pack.new(num_of_packs,pack_units,pack_price,@item_total)
				@packs.push(pack)

				Tracer.debug "\nAdded " + num_of_packs.to_s + " packs of " + pack_units.to_s + "-pack at $" + \
							pack_price.to_s + "per pack, total: $" + @item_total.round(2).to_s + " to order item."

				# How much remains after we move those units to those packs?
				@remaining_units -= (num_of_packs * pack_units)

			end

		end

		if @remaining_units > 0
			Tracer.flash "\nExtra Remaining Unit: " + @remaining_units.to_s + " that cannot be grouped into a pack."
		end
	end
# attr_reader :requested_quantity # requested item (object) Item class
# attr_reader :menu_item # requested item (object) Item class
# attr_reader :packs # type: Pack breakdown of requested item into packages, this is an array of the OrderPackage class
attr_reader :requested_quantity # requested item (object) Item class
attr_reader :menu_item # requested item (object) Item class
attr_reader :packs # type: Pack breakdown of requested item into packages, this is an array of the OrderPackage class
attr_reader : requested_quantity # requested item ( object ) Item class attr_reader : menu_item # requested item ( object ) Item class attr_reader : packs # type : Pack breakdown of requested item into packages this is an array of the OrderPackage class
def add_packs()	
		packages_for_this_item.each do |pack_units, pack_price|
			if @remaining_units > pack_units
				Tracer.debug "remaining_units: " + @remaining_units.to_s + " pack_units: " + pack_units.to_s
				num_of_packs = @remaining_units / pack_units
				@item_total += num_of_packs * pack_price
				pack = Pack.new(num_of_packs,pack_units,pack_price,@item_total)
				@packs.push(pack)
				Tracer.debug "\nAdded " + num_of_packs.to_s + " packs of " + pack_units.to_s + "-pack at $" + \
							pack_price.to_s + "per pack, total: $" + @item_total.round(2).to_s + " to order item."
				@remaining_units -= (num_of_packs * pack_units)
			end
		end
		if @remaining_units > 0
			Tracer.flash "\nExtra Remaining Unit: " + @remaining_units.to_s + " that cannot be grouped into a pack."
		end
	end
def add_packs ( ) packages_for_this_item . each do | pack_units , pack_price | if @remaining_units > pack_units Tracer . debug "remaining_units: " + @remaining_units . to_s + " pack_units: " + pack_units . to_s num_of_packs = @remaining_units / pack_units @item_total += num_of_packs * pack_price pack = Pack . new ( num_of_packs , pack_units , pack_price , @item_total ) @packs . push ( pack ) Tracer . debug "\nAdded " + num_of_packs . to_s + " packs of " + pack_units . to_s + "-pack at $" + pack_price . to_s + "per pack, total: $" + @item_total . round ( 2 ) . to_s + " to order item." @remaining_units -= ( num_of_packs * pack_units ) end end if @remaining_units > 0 Tracer . flash "\nExtra Remaining Unit: " + @remaining_units . to_s + " that cannot be grouped into a pack." end end
attr_reader :requested_quantity # requested item (object) Item class
attr_reader :menu_item # requested item (object) Item class
attr_reader :packs # type: Pack breakdown of requested item into packages, this is an array of the OrderPackage class
attr_reader : requested_quantity # requested item ( object ) Item class attr_reader : menu_item # requested item ( object ) Item class attr_reader : packs # type : Pack breakdown of requested item into packages this is an array of the OrderPackage class
# If there are more remaining units than in this package, create a pack and see how many packs you need. # How many packs of this package? # How much remains after we move those units to those packs?