Skip to Content Skip to Search
Methods
C
N

Class Public methods

new(amount, currency)

# File app/services/service/currency_converter.rb, line 3
def initialize(amount, currency)
  @currency = currency.downcase
  @amount = amount
end

Instance Public methods

convert_to(currency)

# File app/services/service/currency_converter.rb, line 8
def convert_to(currency)
  return @amount unless currency

  currency = currency.downcase
  on_usd = convert_to_usd
  return on_usd if currency == "usd"

  rate = get_rate(currency)
  on_usd * rate if on_usd && on_usd > 0 && rate && rate > 0
end