Class: Factbase::IndexedGt
- Inherits:
-
Object
- Object
- Factbase::IndexedGt
- Defined in:
- lib/factbase/indexed/indexed_gt.rb
Overview
Indexed term ‘gt’.
Instance Method Summary collapse
-
#initialize(term, idx) ⇒ IndexedGt
constructor
A new instance of IndexedGt.
- #predict(maps, _fb, params) ⇒ Object
Constructor Details
#initialize(term, idx) ⇒ IndexedGt
Returns a new instance of IndexedGt.
8 9 10 11 |
# File 'lib/factbase/indexed/indexed_gt.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 |
# File 'lib/factbase/indexed/indexed_gt.rb', line 13 def predict(maps, _fb, params) op1, op2 = @term.operands return unless op1.is_a?(Symbol) && _scalar?(op2) prop = op1.to_s target = op2.is_a?(Symbol) ? params[op2.to_s]&.first : op2 return maps || [] if target.nil? key = [maps.object_id, prop, :facts] @idx[key] ||= { facts: [], count: 0 } entry = @idx[key] _feed(maps.to_a, entry, prop) matched = _search(entry, target) maps.respond_to?(:repack) ? maps.repack(matched) : matched end |