Class: Factbase::IndexedOne
- Inherits:
-
Object
- Object
- Factbase::IndexedOne
- Defined in:
- lib/factbase/indexed/indexed_one.rb
Overview
Indexed term ‘one’.
Instance Method Summary collapse
-
#initialize(term, idx) ⇒ IndexedOne
constructor
A new instance of IndexedOne.
- #predict(maps, _fb, _params) ⇒ Object
Constructor Details
#initialize(term, idx) ⇒ IndexedOne
Returns a new instance of IndexedOne.
8 9 10 11 |
# File 'lib/factbase/indexed/indexed_one.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 |
# File 'lib/factbase/indexed/indexed_one.rb', line 13 def predict(maps, _fb, _params) prop = @term.operands.first.to_s key = [maps.object_id, prop, @term.op] @idx[key] ||= { facts: [], count: 0 } entry = @idx[key] _feed(maps.to_a, entry, prop) maps.respond_to?(:repack) ? maps.repack(entry[:facts]) : entry[:facts] end |