class Cash

Public Class Methods

cash_value(coin) click to toggle source
# File lib/machine/cash.rb, line 12
def cash_value(coin)
  coin_map[coin]
end
cash_values(coins) click to toggle source
# File lib/machine/cash.rb, line 4
def cash_values(coins)
  coins.map { |coin| coin_map[coin] }
end
string_value(coin) click to toggle source
# File lib/machine/cash.rb, line 16
def string_value(coin)
  to_string[coin]
end
string_values(coins) click to toggle source
# File lib/machine/cash.rb, line 8
def string_values(coins)
  coins.map { |coin| to_string[coin] }
end
valid_coins() click to toggle source
# File lib/machine/cash.rb, line 20
def valid_coins
  coin_map.keys
end

Private Class Methods

coin_map() click to toggle source
# File lib/machine/cash.rb, line 24
        def coin_map
  {
    "1c" => 1,
    "2c" => 2,
    "5c" => 5,
    "10c" => 10,
    "20c" => 20,
    "50c" => 50,
    "€1" => 100,
    "€2" => 200
  }
end
to_string() click to toggle source
# File lib/machine/cash.rb, line 37
        def to_string
  {
    1 => "1c",
    2 => "2c",
    5 => "5c",
    10 => "10c",
    20 => "20c",
    50 => "50c",
    100 => "€1",
    200 => "€2"
  }
end