Class: Factbase::Size
Overview
Factbase::Size is a term that calculates the size of an operand when evaluated on a given fact.
Instance Method Summary collapse
-
#evaluate(fact, _maps, _fb) ⇒ Integer
Evaluate term on a fact.
-
#initialize(operands) ⇒ Size
constructor
Constructor.
Methods included from TermShared
Constructor Details
#initialize(operands) ⇒ Size
Constructor.
13 14 15 16 |
# File 'lib/factbase/terms/size.rb', line 13 def initialize(operands) super() @operands = operands end |
Instance Method Details
#evaluate(fact, _maps, _fb) ⇒ Integer
Evaluate term on a fact.
23 24 25 26 27 28 29 |
# File 'lib/factbase/terms/size.rb', line 23 def evaluate(fact, _maps, _fb) assert_args(1) v = _by_symbol(0, fact) return 0 if v.nil? return 1 unless v.respond_to?(:to_a) v.size end |