Method: ChangeMachine.make_cents

Defined in:
lib/coinstar/change_machine.rb

.make_cents(currency) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/coinstar/change_machine.rb', line 21

def self.make_cents(currency)
  begin
    currency.inject(0) do |cents, (k,v)|
      cents += (CURRENCY[k.to_s.singularize.to_sym] * v)
      cents
    end
  rescue NoMethodError
    raise 'Unknown currency type'
  end
end