Sha256: d693efc0a0fe1094d19d20e0269d764eeb02483a36dde140a46bdfc037118121

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

module Orders
  # Represents DOM (OrderBook) for one security
  # индекс стакана по цене
  class OrderBook < IndexedList

    attr_accessor :isin_id, :changed

    def initialize isin_id
      @isin_id = isin_id
      @changed = true
      super()
    end

    def index item
      item.price
    end

    def add item
      if item.price > 0
        @changed = true # Marking DOM as changed
        item.order_book = self
        super
      else
        self
      end
    end

    # Does not call super!
    def remove item
      @changed = true if delete index item # Marking DOM as changed
      item.order_book = nil
      self
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
orders-0.0.4 lib/orders/order_book.rb
orders-0.0.3 lib/orders/order_book.rb