Module: Veritas::Optimizer::Function::Binary::ConstantOperands

Included in:
Connective::Binary::ConstantOperands, Numeric::ConstantOperands, Predicate::ConstantOperands
Defined in:
lib/veritas/optimizer/function/binary.rb

Overview

Optimize when the operands are constants

Instance Method Summary collapse

Instance Method Details

#optimizable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if the operands are constants

Returns:

  • (Boolean)


63
64
65
66
# File 'lib/veritas/optimizer/function/binary.rb', line 63

def optimizable?
  util = Util
  util.constant?(left) && util.constant?(right)
end

#optimizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluate the operands and return the constant

Returns:

  • (Object)


73
74
75
# File 'lib/veritas/optimizer/function/binary.rb', line 73

def optimize
  operation.class.call(left, right)
end