Class: Till
- Inherits:
-
Object
- Object
- Till
- Defined in:
- lib/till.rb
Instance Method Summary collapse
-
#initialize(prices) ⇒ Till
constructor
A new instance of Till.
- #total_for(basket) ⇒ Object
Constructor Details
#initialize(prices) ⇒ Till
Returns a new instance of Till.
2 3 4 |
# File 'lib/till.rb', line 2 def initialize prices @prices = prices end |
Instance Method Details
#total_for(basket) ⇒ Object
6 7 8 |
# File 'lib/till.rb', line 6 def total_for basket basket.items.inject(0){|total, item| total += @prices[item]} end |