Class: Factbase::Traced
- Defined in:
- lib/factbase/terms/traced.rb
Overview
A class representing a traced term in the factbase. This class is responsible for evaluating a term and printing its evaluation result for tracing purposes.
Instance Method Summary collapse
-
#evaluate(fact, maps, fb) ⇒ Object
Evaluate term on a fact.
-
#initialize(operands) ⇒ Traced
constructor
Constructor.
Methods included from TermShared
Constructor Details
#initialize(operands) ⇒ Traced
Constructor.
14 15 16 17 18 |
# File 'lib/factbase/terms/traced.rb', line 14 def initialize(operands) super() @operands = operands @op = 'traced' end |
Instance Method Details
#evaluate(fact, maps, fb) ⇒ Object
Evaluate term on a fact.
25 26 27 28 29 30 31 32 |
# File 'lib/factbase/terms/traced.rb', line 25 def evaluate(fact, maps, fb) assert_args(1) t = @operands[0] raise "A term is expected, but '#{t}' provided" unless t.is_a?(Factbase::Term) r = t.evaluate(fact, maps, fb) puts "#{self} -> #{r}" r end |