Class: Cryptoexchange::Exchanges::Coinrail::Services::Market

Inherits:
Services::Market show all
Defined in:
lib/cryptoexchange/exchanges/coinrail/services/market.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Services::Market

#fetch_using_post

Class Method Details

.supports_individual_ticker_query?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/cryptoexchange/exchanges/coinrail/services/market.rb', line 6

def supports_individual_ticker_query?
  false
end

Instance Method Details

#adapt(output, market_pair) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cryptoexchange/exchanges/coinrail/services/market.rb', line 41

def adapt(output, market_pair)
  ticker = Cryptoexchange::Models::Ticker.new
  ticker.base = market_pair.base
  ticker.target = market_pair.target

  ticker.market = Coinrail::Market::NAME
  ticker.last = NumericHelper.to_d(output["last24_price"])
  ticker.volume = NumericHelper.to_d(output["trade_amount"])
  ticker.timestamp = nil
  ticker.payload = output
  ticker
end

#adapt_all(output) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cryptoexchange/exchanges/coinrail/services/market.rb', line 29

def adapt_all(output)
  output.map do |pair|
      base, target = pair["currency"].split("-")
      market_pair = Cryptoexchange::Models::MarketPair.new(
                    base: base,
                    target: target,
                    market: Coinrail::Market::NAME
                  )
      adapt(pair, market_pair)
  end
end

#fetchObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cryptoexchange/exchanges/coinrail/services/market.rb', line 11

def fetch
  raw_output = super(ticker_url)
  output = []
  raw_output.map do |market|
    if market[0] == "btc_market" || market[0] == "krw_market"
      market[1].each { |pair|
        output.push(pair)
      }
    end
  end
  adapt_all(output)
end

#ticker_urlObject



24
25
26
27
# File 'lib/cryptoexchange/exchanges/coinrail/services/market.rb', line 24

def ticker_url
  # No API endpoint available to obtain tickers (as at 29/01/2018), hence the URL below:
  "#{Cryptoexchange::Exchanges::Coinrail::Market::TICKER_URL}"
end