class Ubea::CurrencyConverter::RateExchange

Constants

URL

Public Class Methods

get_json(url) click to toggle source
# File lib/ubea/currency_converter.rb, line 50
def self.get_json(url)
  Retryable.retryable(tries: 3, sleep: 1) do
    json = open(url).read
    JSON.parse(json)
  end
end
get_rate(from, to) click to toggle source
# File lib/ubea/currency_converter.rb, line 43
def self.get_rate(from, to)
  url = URL % [from, to]
  json = get_json(url)
  rate = json["rate"].to_s
  BigDecimal.new(rate)
end