Sha256: a7e585a576375ee32f4a7a8834ce7027247dee50bbc527aebdb389e0f5895342
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
module Veritas class Optimizer module Logic module Connective # Abstract base class representing Negation optimizations class Negation < Optimizer # The optimized operand # # @return [Expression] # # @api private attr_reader :operand # Initialize a Unary optimizer # # @return [undefined] # # @api private def initialize(*) super @operand = optimize_operand end private # Optimize the operand # # @return [Expression] # # @api private def optimize_operand # TODO: move Predicate.optimize_operand to a better location Predicate.optimize_operand(operation.operand) end # Optimize when the operand can be inverted class InvertibleOperand < self # Test if the operand can be inverted # # @return [Boolean] # # @api private def optimizable? operand.respond_to?(:inverse) end # A Negation of an Expression is equivalent to the inverted Expression # # @return [Expression] # # @api private def optimize operand.inverse end end # class InvertibleOperand Veritas::Logic::Connective::Negation.optimizer = chain( InvertibleOperand ) end # class Negation end # module Connective end # module Logic end # class Optimizer end # module Veritas
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.2 | lib/veritas/optimizer/logic/connective/negation.rb |