Sha256: 3fabc48c94f77cdeb6dcd25f43ac0a333487c81b6e7b86cf70866840aab97770

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

module Veritas
  class Optimizer
    module Logic
      class Predicate

        # Abstract base class representing GreaterThanOrEqualTo optimizations
        class GreaterThanOrEqualTo < self
          include Comparable

          # Optimize when the operands are always false
          class AlwaysFalse < self
            include Comparable::NeverComparable
            include Predicate::AlwaysFalse

            # Test if the operands are always false
            #
            # @return [Boolean]
            #
            # @api private
            def optimizable?
              super || LessThan::AlwaysTrue.new(operation.inverse).optimizable?
            end

          end # class AlwaysFalse

          # Optimize when the operands are always true
          class AlwaysTrue < self
            include Predicate::AlwaysTrue

            # Test if the operands are always true
            #
            # @return [Boolean]
            #
            # @api private
            def optimizable?
              operation = self.operation
              GreaterThan::AlwaysTrue.new(operation).optimizable? ||
              Equality::AlwaysTrue.new(operation).optimizable?
            end

          end # class AlwaysTrue

          Veritas::Logic::Predicate::GreaterThanOrEqualTo.optimizer = chain(
            ConstantOperands,
            AlwaysFalse,
            AlwaysTrue,
            NormalizableOperands
          )

        end # class GreaterThanOrEqualTo
      end # class Predicate
    end # module Logic
  end # class Optimizer
end # module Veritas

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritas-0.0.2 lib/veritas/optimizer/logic/predicate/greater_than_or_equal_to.rb
veritas-0.0.1 lib/veritas/optimizer/logic/predicate/greater_than_or_equal_to.rb