Class: Factbase::IndexedOr

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/indexed/indexed_or.rb

Overview

Indexed term ‘or’.

Instance Method Summary collapse

Constructor Details

#initialize(term, idx) ⇒ IndexedOr

Returns a new instance of IndexedOr.



8
9
10
11
# File 'lib/factbase/indexed/indexed_or.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
# File 'lib/factbase/indexed/indexed_or.rb', line 13

def predict(maps, fb, params)
  return nil if @idx.nil?
  r = nil
  @term.operands.each do |o|
    n = o.predict(maps, fb, params)
    if n.nil?
      r = nil
      break
    end
    r = maps & [] if r.nil?
    r |= n.to_a
    return maps if r.size > maps.size / 4 # it's big enough already
  end
  r
end