Class: Till

Inherits:
Object
  • Object
show all
Defined in:
lib/till.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTill

Returns a new instance of Till.



7
8
9
# File 'lib/till.rb', line 7

def initialize
  @total = 0
end

Instance Attribute Details

#totalObject (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