Class: Factbase::Max

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

Overview

The ‘max’ term. This term calculates the max value among the evaluated operands.

Constant Summary collapse

MAX =
Factbase::Best.new { |v, b| v > b }

Instance Method Summary collapse

Methods included from TermShared

#to_s

Constructor Details

#initialize(operands) ⇒ Max

Constructor.

Parameters:

  • operands (Array)

    Operands



17
18
19
20
21
# File 'lib/factbase/terms/max.rb', line 17

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

Instance Method Details

#evaluate(_fact, maps, _fb) ⇒ Object

Evaluate term on a fact.

Parameters:

Returns:

  • (Object)

    The max value among the evaluated operands



28
29
30
31
# File 'lib/factbase/terms/max.rb', line 28

def evaluate(_fact, maps, _fb)
  assert_args(1)
  MAX.evaluate(@operands[0], maps)
end