Module: PriceRecord
- Defined in:
- lib/price_record.rb
Class Method Summary collapse
Class Method Details
.getPrice(name) ⇒ Object
13 14 15 16 |
# File 'lib/price_record.rb', line 13 def getPrice name PriceRecord.initialize unless @price_list @price_list[name] end |
.initialize ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/price_record.rb', line 4 def initialize @price_list = {} price_list_string = "orange = £30 apple = 20p bread = £50 tomato = 25p cereal = £20" price_list_string.scan(/(\w+)\s=\s[£]*([\d,\.]*)/).each do |match| @price_list[match[0]] = price_in_pence(match[1]) end end |