Class: Factbase::Inverted
- Defined in:
- lib/factbase/terms/inverted.rb
Overview
Evaluates whether a value is inverted within a given factbase context.
Instance Method Summary collapse
-
#evaluate(_fact, _maps, _fb) ⇒ Boolean
Evaluate term on a fact.
-
#initialize(operands) ⇒ Inverted
constructor
Constructor.
- #predict(maps, fb, params) ⇒ Object
Methods included from TermShared
Constructor Details
#initialize(operands) ⇒ Inverted
Constructor.
11 12 13 14 15 |
# File 'lib/factbase/terms/inverted.rb', line 11 def initialize(operands) super() @operands = operands @op = 'inverted' end |
Instance Method Details
#evaluate(_fact, _maps, _fb) ⇒ Boolean
Evaluate term on a fact.
22 23 24 |
# File 'lib/factbase/terms/inverted.rb', line 22 def evaluate(_fact, _maps, _fb) true end |
#predict(maps, fb, params) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/factbase/terms/inverted.rb', line 26 def predict(maps, fb, params) assert_args(1) term = @operands[0] raise "A term is expected, but '#{term}' provided" unless term.is_a?(Factbase::Term) fb.query(term, maps).each(fb, params).to_a .reverse .map { |m| m.all_properties.to_h { |k| [k, m[k]] } } end |