Sha256: 88f7b6cdc7407003ab621633ef500cf3ec5c34f9322b72a5171db79e4fbef78c
Contents?: true
Size: 937 Bytes
Versions: 7
Compression:
Stored size: 937 Bytes
Contents
module CurrencyRate class ExmoAdapter < Adapter # No need to use it for fetching, just additional information about supported currencies SUPPORTED_CURRENCIES = %w( ADA BCH BTC BTCZ BTG DASH DOGE DXT EOS ETC ETH EUR GAS GNT GUSD HB HBZ INK KICK LSK LTC MNX NEO OMG PLN QTUM RUB SMART STQ TRX TRY UAH USD USDT WAVES XEM XLM XMR XRP ZEC ZRX ) ANCHOR_CURRENCY = "BTC" FETCH_URL = "https://api.exmo.com/v1/ticker/" def normalize(data) return nil unless super data.reduce({ "anchor" => ANCHOR_CURRENCY }) do |result, (key, value)| if key.split("_")[0] == ANCHOR_CURRENCY result[key.sub("#{self.class::ANCHOR_CURRENCY}_", "")] = BigDecimal(value["avg"].to_s) elsif key.split("_")[1] == ANCHOR_CURRENCY result[key.sub("_#{self.class::ANCHOR_CURRENCY}", "")] = 1 / BigDecimal(value["avg"].to_s) end result end end end end
Version data entries
7 entries across 7 versions & 1 rubygems