Class: Factbase::Empty
Overview
The ‘empty’ term checks for emptiness in the results of a query evaluation.
Instance Method Summary collapse
-
#evaluate(fact, maps, fb) ⇒ Boolean
Evaluate term on a fact.
-
#initialize(operands) ⇒ Empty
constructor
Constructor.
Methods included from TermShared
Constructor Details
#initialize(operands) ⇒ Empty
Constructor.
12 13 14 15 16 |
# File 'lib/factbase/terms/empty.rb', line 12 def initialize(operands) super() @operands = operands @op = :empty end |
Instance Method Details
#evaluate(fact, maps, fb) ⇒ Boolean
Evaluate term on a fact.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/factbase/terms/empty.rb', line 23 def evaluate(fact, maps, fb) assert_args(1) term = @operands[0] unless term.is_a?(Factbase::Term) || term.is_a?(Factbase::TermBase) raise "A term is expected, but '#{term}' provided" end # rubocop:disable Lint/UnreachableLoop fb.query(term, maps).each(fb, fact) do return false end # rubocop:enable Lint/UnreachableLoop true end |