Module: Fin::BookManager
Overview
Adds to including List a set of @books, each related to a single security(isin). its items, grouped by item’s isin_id. For example: QuoteBook, DealBook
Instance Method Summary collapse
-
#add?(item) ⇒ Boolean
Overwrites/removes existing item with the same index.
- #books ⇒ Object
- #remove?(item) ⇒ Boolean
Instance Method Details
#add?(item) ⇒ Boolean
Overwrites/removes existing item with the same index
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fin/book_manager.rb', line 23 def add? item if check item old_item = self[index item] remove old_item if old_item # Remove old item with the same index(id) if super books[item.isin_id].add item # Add item to appropriate order book item end end end |
#books ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/fin/book_manager.rb', line 12 def books @books ||= Hash.new do |hash, key| hash[key] = Book.new :isin_id => key, :item_type => @item_type, :book_index => @book_index, :book_condition => @book_condition hash[key] end end |
#remove?(item) ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/fin/book_manager.rb', line 34 def remove? item if super # Removing item from appropriate order book when it's deleted from order list books[item.isin_id].remove item item end end |