Class: Till
- Inherits:
-
Object
- Object
- Till
- Defined in:
- lib/till.rb
Instance Attribute Summary collapse
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #add(names) ⇒ Object
-
#initialize ⇒ Till
constructor
A new instance of Till.
Constructor Details
#initialize ⇒ Till
Returns a new instance of Till.
7 8 9 |
# File 'lib/till.rb', line 7 def initialize @total = 0 end |
Instance Attribute Details
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/till.rb', line 5 def total @total end |
Instance Method Details
#add(names) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/till.rb', line 11 def add names #product = Struct.new(:name, :price) do # def to_s # p " Item name: #{@name}.Item price: #{@price}" # end #end names.each do |name| #@prods||=[] << product.new(name, PriceRecord.getPrice(name)) @total += PriceRecord.getPrice(name) end self end |