class Devilicious::CurrencyConverter::RateExchange
Constants
- URL
Public Class Methods
get_json(url)
click to toggle source
# File lib/devilicious/currency_converter.rb, line 46 def self.get_json(url) 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/devilicious/currency_converter.rb, line 39 def self.get_rate(from, to) url = URL % [from, to] json = get_json(url) rate = json["rate"].to_s BigDecimal.new(rate) end