Files
ruby-checkout/product_in_checkout.rb
T

23 lines
364 B
Ruby

class ProductInCheckout
def initialize(product:, quantity: 0)
@product = product
@quantity = quantity
end
def product_id
@product.id
end
def quantity
@quantity
end
def add_quantity(quantity)
@quantity += quantity
end
def total
(@product.price * quantity) - @product.discount.discount_for_quantity(@quantity)
end
end