Sha256: a1aba34f4c1a860bba7da91f53cfaa7bd1b7f3a37c90bb7b5804cb192c8b34d4

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

module Kaesen
  class Client
    attr_reader :markets
    attr_reader :ticker
    attr_reader :balance
    attr_reader :depth

    def initialize
      @markets = []   # [Array]:
                      #   [Market] instance of markets
      @tickers = {}   # [Hash]
                      #   [String]: market name
                      #   [Hash]: hash of ticker
      @depths = {}   # [Hash]:
                      #   [String]: market name
                      #   [Hash]: hash of depth
      @balances = {}  # [Hash]:
                      #   [String]: market name
                      #   [Hash]: hash of depth
    end

    # register the instance of market
    # @parm [Market]
    def push(market)
      @markets.push(market)
    end

    # get the instance of market with key
    # @parms [String] market name
    # @return [Market] or nil
    def get(market_name)
      @markets.each{|m|
        return m if m.name == market_name
      }
      return nil
    end

    # Update market information.
    # @return [hash] hash of ticker
    def update_tickers()
      @markets.each{|m|
        @tickers[m.name] = m.ticker
      }
      @tickers
    end

    # Update market information.
    # @return [hash] hash of depth
    def update_depths()
      @markets.each{|m|
        @depths[m.name] = m.depth
      }
      @depths
    end

    # Update asset information.
    # @return [hash] hash of balance
    def update_balances()
      @markets.each{|m|
        @balances[m.name] = m.balance
      }
      @balances
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kaesen-0.2.1 lib/kaesen/client.rb
kaesen-0.2.0 lib/kaesen/client.rb
kaesen-0.1.1 lib/kaesen/client.rb
kaesen-0.1.0 lib/kaesen/client.rb