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"
GET_TICKER_DETAILED =
"https://api.korbit.co.kr/v1/ticker/detailed"
GET_ORDERBOOK =
"https://api.korbit.co.kr/v1/orderbook"
GET_TRANSACTIONS =
"https://api.korbit.co.kr/v1/transactions"
GET_CONSTANTS =
"https://api.korbit.co.kr/v1/constants"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_method(currency) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/coin/market.rb', line 23

def self.create_method(currency)
  define_method "get_ticker_#{currency}" do
    get_ticker(currency)
  end

  define_method "get_ticker_detailed_#{currency}" do
    get_ticker_detailed(currency)
  end

  define_method "get_orderbook_#{currency}" do
    get_orderbook(currency)
  end

  define_method "get_transactions_#{currency}" do
    get_transactions(currency)
  end

  define_method "get_constants_#{currency}" do
    get_constants(currency)
  end
end

Instance Method Details

#get_constants(currency_pair) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/coin/market.rb', line 51

def get_constants(currency_pair)
  unless is_supported_currency_pair(currency_pair)
    raise Exceptions::CannotSupportException, __method__ + currency_pair
  end

  transactions = _process_api(get_constants_with_currency_pair(currency_pair))

  if transactions.nil?
    raise Exceptions::NetworkException, __method__ + currency_pair
  end
  transactions
end

#get_orderbook(currency_pair) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/coin/market.rb', line 77

def get_orderbook(currency_pair)
  unless is_supported_currency_pair(currency_pair)
    raise Exceptions::CannotSupportException, __method__ + currency_pair
  end

  orderbook = _process_api(get_orderbook_with_currency_pair(currency_pair))

  if orderbook.nil?
    raise Exceptions::NetworkException, __method__ + currency_pair
  end
  orderbook
end

#get_ticker(currency_pair) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/coin/market.rb', line 103

def get_ticker(currency_pair)
  unless is_supported_currency_pair(currency_pair)
    raise Exceptions::CannotSupportException, __method__ + currency_pair
  end

  ticker = _process_api(get_ticker_with_currency_pair(currency_pair))

  if ticker.nil?
    raise Exceptions::NetworkException, __method__ + currency_pair
  end
  ticker
end

#get_ticker_detailed(currency_pair) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/coin/market.rb', line 90

def get_ticker_detailed(currency_pair)
  unless is_supported_currency_pair(currency_pair)
    raise Exceptions::CannotSupportException, __method__ + currency_pair
  end

  ticker = _process_api(get_ticker_detailed_with_currency_pair(currency_pair))

  if ticker.nil?
    raise Exceptions::NetworkException, __method__ + currency_pair
  end
  ticker
end

#get_transactions(currency_pair) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/coin/market.rb', line 64

def get_transactions(currency_pair)
  unless is_supported_currency_pair(currency_pair)
    raise Exceptions::CannotSupportException, __method__ + currency_pair
  end

  transactions = _process_api(get_transactions_with_currency_pair(currency_pair))

  if transactions.nil?
    raise Exceptions::NetworkException, __method__ + currency_pair
  end
  transactions
end