Combining Purchases

I am able to combine purchase, however the quantity is not showing,
any suggestions?
Code:

class Basket

attr_reader :purchases
attr_reader :total

def initialize
@purchases = []
@total = 0.0
end

def add_purchase(cart)
@purchases << Purchase.buy_one(cart)
@total += cart.price
end

def add_purchase(cart)
appendFlag = true
for purchase in @purchases
if (cart.id == purchase.cart.id)
appendFlag = false
purchase.quantity += 1
end
end
if(appendFlag)
@purchases << Purchase.buy_one(cart)
end
@total += cart.price
end

def clear
@purchases = []
@total = 0.0
end

end