Class: Checkout
- Inherits:
-
Object
- Object
- Checkout
- Defined in:
- lib/wunder/checkout.rb
Instance Attribute Summary collapse
-
#adjustment ⇒ Object
Returns the value of attribute adjustment.
-
#basket ⇒ Object
Returns the value of attribute basket.
-
#promotional_rules ⇒ Object
Returns the value of attribute promotional_rules.
Instance Method Summary collapse
- #applied_promotional_rules ⇒ Object
-
#initialize(promotional_rules) ⇒ Checkout
constructor
A new instance of Checkout.
- #remove_scan(product) ⇒ Object
- #scan(product) ⇒ Object
- #total ⇒ Object
Constructor Details
Instance Attribute Details
#adjustment ⇒ Object
Returns the value of attribute adjustment.
5 6 7 |
# File 'lib/wunder/checkout.rb', line 5 def adjustment @adjustment end |
#basket ⇒ Object
Returns the value of attribute basket.
5 6 7 |
# File 'lib/wunder/checkout.rb', line 5 def basket @basket end |
#promotional_rules ⇒ Object
Returns the value of attribute promotional_rules.
5 6 7 |
# File 'lib/wunder/checkout.rb', line 5 def promotional_rules @promotional_rules end |
Instance Method Details
#applied_promotional_rules ⇒ Object
25 26 27 |
# File 'lib/wunder/checkout.rb', line 25 def applied_promotional_rules adjustment.eligible_promotional_rules if adjustment end |
#remove_scan(product) ⇒ Object
16 17 18 |
# File 'lib/wunder/checkout.rb', line 16 def remove_scan(product) basket.remove_item(product) end |
#scan(product) ⇒ Object
12 13 14 |
# File 'lib/wunder/checkout.rb', line 12 def scan(product) basket.add_item(product) end |
#total ⇒ Object
20 21 22 23 |
# File 'lib/wunder/checkout.rb', line 20 def total @adjustment = Adjustment.new(basket, promotional_rules) @adjustment.calculate_total end |