Class: Mcoin::Market::Kraken
Overview
:nodoc:
Constant Summary collapse
- ENDPOINT =
rubocop:disable Metrics/LineLength
'https://api.kraken.com/0/public/Ticker?pair=%<type>s%<currency>s'
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(type, currency) ⇒ Kraken
constructor
A new instance of Kraken.
- #swap_btc(type) ⇒ Object
- #to_ticker ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(type, currency) ⇒ Kraken
Returns a new instance of Kraken.
10 11 12 13 |
# File 'lib/mcoin/market/kraken.rb', line 10 def initialize(type, currency) type = swap_btc(type) super end |
Instance Method Details
#fetch ⇒ Object
27 28 29 30 31 32 |
# File 'lib/mcoin/market/kraken.rb', line 27 def fetch super return self if @data['result'].nil? @data = @data.dig('result', "X#{@type}Z#{@currency}") self end |
#swap_btc(type) ⇒ Object
34 35 36 37 38 |
# File 'lib/mcoin/market/kraken.rb', line 34 def swap_btc(type) return :BTC if type == :XBT return :XBT if type == :BTC type end |
#to_ticker ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mcoin/market/kraken.rb', line 15 def to_ticker fetch Data::Ticker.new( :Kraken, swap_btc(@type), @currency, last: @data['c'][0], ask: @data['a'][0], bid: @data['b'][0], low: @data['l'][1], high: @data['h'][1], volume: @data['v'][1] ) end |