class Coin::Market::Korbit
Constants
- GET_CONSTANTS
- GET_ORDERBOOK
- GET_TICKER
- GET_TICKER_DETAILED
- GET_TRANSACTIONS
Public Class Methods
create_method(currency)
click to toggle source
# 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
Public Instance Methods
get_constants(currency_pair)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
_process_api(url)
click to toggle source
# File lib/coin/market.rb, line 118 def _process_api(url) http_response = RestClient.get(url) JSON.parse(http_response.body) end
get_constants_with_currency_pair(currency_pair)
click to toggle source
# File lib/coin/market.rb, line 139 def get_constants_with_currency_pair(currency_pair) GET_CONSTANTS + "?=currency_pair=" + currency_pair end
get_orderbook_with_currency_pair(currency_pair)
click to toggle source
# File lib/coin/market.rb, line 131 def get_orderbook_with_currency_pair(currency_pair) GET_ORDERBOOK + "?=currency_pair=" + currency_pair end
get_ticker_detailed_with_currency_pair(currency_pair)
click to toggle source
# File lib/coin/market.rb, line 127 def get_ticker_detailed_with_currency_pair(currency_pair) GET_TICKER_DETAILED + "?=currency_pair=" + currency_pair end
get_ticker_with_currency_pair(currency_pair)
click to toggle source
# File lib/coin/market.rb, line 123 def get_ticker_with_currency_pair(currency_pair) GET_TICKER + "?=currency_pair=" + currency_pair end
get_transactions_with_currency_pair(currency_pair)
click to toggle source
# File lib/coin/market.rb, line 135 def get_transactions_with_currency_pair(currency_pair) GET_TRANSACTIONS + "?=currency_pair=" + currency_pair end
is_supported_currency_pair(currency_pair)
click to toggle source
# File lib/coin/market.rb, line 143 def is_supported_currency_pair(currency_pair) SUPPORT_CURRENCY.include?(currency_pair) end