Sha256: 0adf9a27c1a2cd82e9fbfe208f9413e01f11b8347f8a25eea092f2f1e4fdee15

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

module Mcoin
  module Market
    # :nodoc:
    class Zaif < Base
      ENDPOINT = 'https://api.zaif.jp/api/1/ticker/%<type>s_%<currency>s'

      def watch(type, currency)
        type = swap_cms(type.to_s.downcase)
        @pairs.add({ type: type, currency: currency.to_s.downcase })
      end

      private

      def build_ticker(pair, response)
        Data::Ticker.new(
          :Zaif, swap_cms(pair[:type]).upcase, pair[:currency].upcase,
          last: response['last'].to_s,
          ask: response['ask'].to_s, bid: response['bid'].to_s,
          high: response['high'].to_s, low: response['low'].to_s,
          volume: response['volume'],
          timestamp: Time.now.to_i
        )
      end

      def swap_cms(type)
        return 'erc20.cms' if type == 'cms'
        return 'cms' if type == 'erc20.cms'
        type
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mcoin-0.6.1 lib/mcoin/market/zaif.rb
mcoin-0.6.0 lib/mcoin/market/zaif.rb