Class: Hola::Offer
- Inherits:
-
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
8
9
10
11
|
# File 'lib/hola/offer.rb', line 8
def initialize(product:, quantity:)
@product = product
@quantity = quantity
end
|
Instance Attribute Details
#quantity ⇒ Object
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
21
22
23
|
# File 'lib/hola/offer.rb', line 21
def applied?
false
end
|
#name ⇒ Object
13
14
15
|
# File 'lib/hola/offer.rb', line 13
def name
""
end
|
#price ⇒ Object
17
18
19
|
# File 'lib/hola/offer.rb', line 17
def price
@price ||= product.price
end
|
#subtotal ⇒ Object
25
26
27
|
# File 'lib/hola/offer.rb', line 25
def subtotal
price * quantity
end
|