Class: Factbase::When
Overview
It evaluates the operands based on a logical “when” operation.
Instance Method Summary collapse
-
#evaluate(fact, maps, fb) ⇒ Boolean
Evaluate term on a fact.
-
#initialize(operands) ⇒ When
constructor
Constructor.
Methods included from TermShared
Constructor Details
#initialize(operands) ⇒ When
Constructor.
12 13 14 15 16 |
# File 'lib/factbase/terms/when.rb', line 12 def initialize(operands) super() @operands = operands @op = :when end |
Instance Method Details
#evaluate(fact, maps, fb) ⇒ Boolean
Evaluate term on a fact.
23 24 25 26 27 28 |
# File 'lib/factbase/terms/when.rb', line 23 def evaluate(fact, maps, fb) assert_args(2) a = @operands[0] b = @operands[1] !a.evaluate(fact, maps, fb) || (a.evaluate(fact, maps, fb) && b.evaluate(fact, maps, fb)) end |