Sha256: 6de700444e8196b292b8e20612456eafc4cea9ac48bce14ea319eb22e7b685b1
Contents?: true
Size: 708 Bytes
Versions: 7
Compression:
Stored size: 708 Bytes
Contents
module CurrencyRate class BitstampAdapter < Adapter SUPPORTED_CURRENCIES = %w( BCH ETH LTC XRP ) ANCHOR_CURRENCY = "BTC" FETCH_URL = Hash[SUPPORTED_CURRENCIES.collect { |currency| [ currency, "https://www.bitstamp.net/api/v2/ticker/#{currency}#{ANCHOR_CURRENCY}/".downcase ] }] FETCH_URL["USD"] = "https://www.bitstamp.net/api/ticker/" def normalize(data) return nil unless super data.reduce({ "anchor" => ANCHOR_CURRENCY }) do |result, (key, value)| if key == "USD" result[key] = BigDecimal(value["last"].to_s) else result[key] = 1 / BigDecimal(value["last"].to_s) end result end end end end
Version data entries
7 entries across 7 versions & 1 rubygems