Module: Veritas::Optimizer::Function::Unary::ConstantOperand

Included in:
Connective::Negation::ConstantOperand, Numeric::ConstantOperand, String::Length::ConstantOperand
Defined in:
lib/veritas/optimizer/function/unary.rb

Overview

Optimize when the operand is constant

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 operand is constant

Returns:

  • (Boolean)


46
47
48
# File 'lib/veritas/optimizer/function/unary.rb', line 46

def optimizable?
  Util.constant?(operand)
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 operand and return the constant

Returns:

  • (Object)


55
56
57
# File 'lib/veritas/optimizer/function/unary.rb', line 55

def optimize
  operation.class.call(operand)
end