Class: Hola::Offer

Inherits:
Object
  • Object
show all
Defined in:
lib/hola/offer.rb,
lib/hola/offer/no_offer.rb,
lib/hola/offer/get_one_free.rb,
lib/hola/offer/strawberry_bulk_discount.rb,
lib/hola/offer/two_thirds_bulk_discount.rb

Defined Under Namespace

Classes: GetOneFree, NoOffer, StrawberryBulkDiscount, TwoThirdsBulkDiscount

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product:, quantity:) ⇒ Offer

Returns a new instance of Offer.



8
9
10
11
# File 'lib/hola/offer.rb', line 8

def initialize(product:, quantity:)
  @product = product
  @quantity = quantity
end

Instance Attribute Details

#quantityObject (readonly)

Returns the value of attribute quantity.



6
7
8
# File 'lib/hola/offer.rb', line 6

def quantity
  @quantity
end

Instance Method Details

#applied?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/hola/offer.rb', line 21

def applied?
  false
end

#nameObject



13
14
15
# File 'lib/hola/offer.rb', line 13

def name
  ""
end

#priceObject



17
18
19
# File 'lib/hola/offer.rb', line 17

def price
  @price ||= product.price
end

#subtotalObject



25
26
27
# File 'lib/hola/offer.rb', line 25

def subtotal
  price * quantity
end