Class: Factbase::Either
- Defined in:
- lib/factbase/terms/either.rb
Overview
Represents a logical “either” term. The term evaluates its operands and returns the first non-nil value.
Instance Method Summary collapse
-
#evaluate(fact, maps, fb) ⇒ Object, Boolean
Evaluate term on a fact.
-
#initialize(operands) ⇒ Either
constructor
Constructor.
Methods included from TermShared
Constructor Details
#initialize(operands) ⇒ Either
Constructor.
13 14 15 16 17 |
# File 'lib/factbase/terms/either.rb', line 13 def initialize(operands) super() @operands = operands @op = :either end |
Instance Method Details
#evaluate(fact, maps, fb) ⇒ Object, Boolean
Evaluate term on a fact.
25 26 27 28 29 30 |
# File 'lib/factbase/terms/either.rb', line 25 def evaluate(fact, maps, fb) assert_args(2) v = _values(0, fact, maps, fb) return v unless v.nil? _values(1, fact, maps, fb) end |