Class: Factbase::Count

Inherits:
TermBase show all
Defined in:
lib/factbase/terms/count.rb

Overview

The ‘count’ term is used to perform a count operation on a set of maps.

Instance Method Summary collapse

Methods included from TermShared

#to_s

Constructor Details

#initialize(operands) ⇒ Count

Constructor.

Parameters:

  • operands (Array)

    Operands



11
12
13
14
15
# File 'lib/factbase/terms/count.rb', line 11

def initialize(operands)
  super()
  @operands = operands
  @op = :count
end

Instance Method Details

#evaluate(_fact, maps, _fb) ⇒ Integer

Evaluate term on a fact.

Parameters:

Returns:

  • (Integer)

    The count of maps



22
23
24
# File 'lib/factbase/terms/count.rb', line 22

def evaluate(_fact, maps, _fb)
  maps.size
end