Skip to content

Instantly share code, notes, and snippets.

Created February 17, 2018 14:22
Show Gist options
  • Save anonymous/e174e0b9fed1dc2023823578238bf4f2 to your computer and use it in GitHub Desktop.
Save anonymous/e174e0b9fed1dc2023823578238bf4f2 to your computer and use it in GitHub Desktop.
class Currency
def convert(amount, currency, target_currency)
price = amount
if currency == "USD" && target_currency == "BRL"
price = (amount * 3.16)
elsif currency == "BRL" && target_currency == "USD"
price = (amount / price)
elsif currency == "USD" && target_currency == "EUR"
price = (amount * 0.80)
elsif currency == "EUR" && target_currency == "USD"
price = (amount / price)
end
price
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment