Class: Coin::Market::Korbit

Inherits:
Object
  • Object
show all
Defined in:
lib/coin/market.rb

Constant Summary collapse

GET_TICKER =
"https://api.korbit.co.kr/v1/ticker"

Instance Method Summary collapse

Instance Method Details

#get_ticker(currency_pair) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/coin/market.rb', line 32

def get_ticker(currency_pair)
  unless is_supported_ticker(currency_pair)
    raise Exceptions::CannotSupportException, 'get_ticker_' + currency_pair
  end
  http_response = RestClient.get(make_currency_pair(currency_pair))
  ticker = JSON.parse(http_response.body)
  if ticker.nil?
    raise Exceptions::NetworkException, 'get_ticker_' + currency_pair
  end
  ticker
end

#get_ticker_bch_krw ⇒ Object



28
29
30
# File 'lib/coin/market.rb', line 28

def get_ticker_bch_krw()
  get_ticker(BCH_KRW)
end

#get_ticker_btc_krw ⇒ Object



16
17
18
# File 'lib/coin/market.rb', line 16

def get_ticker_btc_krw()
  get_ticker(BTC_KRW)
end

#get_ticker_eth_krw ⇒ Object



20
21
22
# File 'lib/coin/market.rb', line 20

def get_ticker_eth_krw()
  get_ticker(ETC_KRW)
end

#get_ticker_xrp_krw ⇒ Object



24
25
26
# File 'lib/coin/market.rb', line 24

def get_ticker_xrp_krw()
  get_ticker(XRP_KRW)
end

#is_supported_ticker(currency_pair) ⇒ Object



48
49
50
# File 'lib/coin/market.rb', line 48

def is_supported_ticker(currency_pair)
  currency_pair == BTC_KRW || currency_pair == ETC_KRW || currency_pair == XRP_KRW || currency_pair == BCH_KRW
end

#make_currency_pair(currency_pair) ⇒ Object



44
45
46
# File 'lib/coin/market.rb', line 44

def make_currency_pair(currency_pair)
  GET_TICKER + "?=currency_pair=" + currency_pair
end