class BtcRates::Rates

Constants

EXCHANGES

Attributes

api[R]
path[R]

Public Class Methods

new(exchange, options = {}) click to toggle source
# File lib/btcrates/rates.rb, line 23
def initialize(exchange, options = {})
  raise BtcRates::InvalidError, 'Please enter an api as an argument. i.e. :bitfinex, :bitstamp :ok_coin_us etc.' unless EXCHANGES[exchange]
  @api = EXCHANGES[exchange][0]
  @path = EXCHANGES[exchange][1] if options[:rate]
end

Public Instance Methods

perform() click to toggle source
# File lib/btcrates/rates.rb, line 33
def perform
  parsed_response = response =~ /[abc]/ ? JSON.parse(response) : response
  path ? parsed_response.dig(*path) : parsed_response
end
response() click to toggle source
# File lib/btcrates/rates.rb, line 29
def response
  @response ||= BtcRatesApi.make_http_call(api)
end