Class: Hola::Offer
- Inherits:
-
Object
- Object
- Hola::Offer
- 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
Direct Known Subclasses
GetOneFree, NoOffer, StrawberryBulkDiscount, TwoThirdsBulkDiscount
Defined Under Namespace
Classes: GetOneFree, NoOffer, StrawberryBulkDiscount, TwoThirdsBulkDiscount
Instance Attribute Summary collapse
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
Instance Method Summary collapse
- #applied? ⇒ Boolean
-
#initialize(product:, quantity:) ⇒ Offer
constructor
A new instance of Offer.
- #name ⇒ Object
- #price ⇒ Object
- #subtotal ⇒ Object
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
#quantity ⇒ Object (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
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 |