Class: Factbase::IndexedNot
- Inherits:
-
Object
- Object
- Factbase::IndexedNot
- Defined in:
- lib/factbase/indexed/indexed_not.rb
Overview
Indexed term ‘not’.
Instance Method Summary collapse
-
#initialize(term, idx) ⇒ IndexedNot
constructor
A new instance of IndexedNot.
- #predict(maps, fb, params) ⇒ Object
Constructor Details
#initialize(term, idx) ⇒ IndexedNot
Returns a new instance of IndexedNot.
8 9 10 11 |
# File 'lib/factbase/indexed/indexed_not.rb', line 8 def initialize(term, idx) @term = term @idx = idx end |
Instance Method Details
#predict(maps, fb, params) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/factbase/indexed/indexed_not.rb', line 13 def predict(maps, fb, params) return nil if @idx.nil? key = [maps.object_id, @term.operands.first, @term.op] if @idx[key].nil? yes = @term.operands.first.predict(maps, fb, params) if yes.nil? @idx[key] = { r: nil } else yes = yes.to_a.to_set @idx[key] = { r: maps.to_a.reject { |m| yes.include?(m) } } end end r = @idx[key][:r] if r.nil? nil else (maps & []) | r end end |