Sha256: 03c62a581ec0c23e6b891150eeceb822a0f5b4c0e3a7114398f8e46ffa4eee52

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

module Veritas
  module Logic
    class Predicate

      # A predicate representing no regexp match between operands
      class NoMatch < Predicate
        include Comparable

        # Return the NoMatch operation
        #
        # @example
        #   NoMatch.operation  # => :!~
        #
        # @return [Symbol]
        #
        # @api public
        def self.operation
          :'!~'
        end

        # Return the inverse predicate class
        #
        # @example
        #   NoMatch.inverse  # => Match
        #
        # @return [Class<Match>]
        #
        # @api public
        def self.inverse
          Match
        end

        # Evaluate the values for no match
        #
        # @example
        #   NoMatch.call(left, right)  # => true or false
        #
        # @param [Object] left
        # @param [Object] right
        #
        # @return [Boolean]
        #
        # @api public
        def self.call(left, right)
          left !~ right
        end unless Object.method_defined?(operation)

        module Methods

          # Compare the left to see if does not match the right
          #
          # @example
          #   no_match = expression.no_match(regexp)
          #
          # @param [Expression] other
          #
          # @return [NoMatch]
          #
          # @api public
          def no_match(regexp)
            NoMatch.new(self, regexp)
          end

        end # module Methods
      end # class NoMatch
    end # class Predicate
  end # module Logic
end # module Veritas

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
veritas-0.0.3 lib/veritas/logic/predicate/no_match.rb
veritas-0.0.2 lib/veritas/logic/predicate/no_match.rb
veritas-0.0.1 lib/veritas/logic/predicate/no_match.rb