Class: Fin::Book
- Inherits:
-
ContainerList
- Object
- IndexedList
- ChangedList
- ContainerList
- Fin::Book
- Defined in:
- lib/fin/book.rb
Overview
Represents a Book (QuoteBook, DealBook, etc…) - collection of all items associated with one security(isin) It is used as additional index by ContainerList subclasses (QuoteList, DealList)
Instance Attribute Summary collapse
-
#isin_id ⇒ Object
(also: #isin)
readonly
Returns the value of attribute isin_id.
Attributes inherited from ContainerList
Attributes inherited from ChangedList
#change_count, #changed, #updated
Instance Method Summary collapse
- #add?(item) ⇒ Boolean
-
#check(item) ⇒ Object
Validation of the item being included.
- #index(item) ⇒ Object
-
#initialize(opts = {}) ⇒ Book
constructor
A new instance of Book.
- #remove?(item) ⇒ Boolean
Methods inherited from ContainerList
#add_message, #add_record, #remove_message, #remove_record
Methods inherited from ChangedList
Constructor Details
#initialize(opts = {}) ⇒ Book
Returns a new instance of Book.
12 13 14 15 16 17 18 |
# File 'lib/fin/book.rb', line 12 def initialize opts = {} @isin_id = opts[:isin_id] @book_index = opts[:book_index] @book_condition = opts[:book_condition] raise "No isin_id given for #{self}" unless @isin_id super end |
Instance Attribute Details
#isin_id ⇒ Object (readonly) Also known as: isin
Returns the value of attribute isin_id.
9 10 11 |
# File 'lib/fin/book.rb', line 9 def isin_id @isin_id end |
Instance Method Details
#add?(item) ⇒ Boolean
37 38 39 40 41 42 |
# File 'lib/fin/book.rb', line 37 def add? item if super item.book = self item end end |
#check(item) ⇒ Object
Validation of the item being included
21 22 23 24 25 26 27 |
# File 'lib/fin/book.rb', line 21 def check item if item.is_a?(@item_type) && item.isin_id == isin_id @book_condition ? @book_condition.call(item) : true else false end end |
#index(item) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/fin/book.rb', line 29 def index item if @book_index @book_index.call(item) else super end end |
#remove?(item) ⇒ Boolean
44 45 46 47 48 49 |
# File 'lib/fin/book.rb', line 44 def remove? item if super item.book = nil item end end |