Sha256: 08f17bd082cb6faa5ac2db59ed7deefdc0625992f01951228b38352130e37800

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8

module Veritas
  class Optimizer
    module Function
      class Predicate

        # Abstract base class representing Exclusion optimizations
        class Exclusion < self
          include Enumerable

          # Optimize when the right operand is empty
          class EmptyRightOperand < self
            include Enumerable::EmptyRightOperand, Predicate::Tautology
          end # class EmptyRightOperand

          # Optimize when the right operand has one entry
          class OneRightOperand < self
            include Enumerable::OneRightOperand

            # An Exclusion with a single right operand is equivalent to an Inequality
            #
            # @return [Inequality]
            #
            # @api private
            def optimize
              Veritas::Function::Predicate::Inequality.new(left, right.first)
            end

          end # class OneRightOperand

          Veritas::Function::Predicate::Exclusion.optimizer = chain(
            ConstantOperands,
            EmptyRightOperand,
            OneRightOperand,
            Enumerable::UnoptimizedOperands
          )

        end # class Exclusion
      end # class Predicate
    end # module Function
  end # class Optimizer
end # module Veritas

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.5 lib/veritas/optimizer/function/predicate/exclusion.rb
veritas-optimizer-0.0.4 lib/veritas/optimizer/function/predicate/exclusion.rb