Sha256: eb67b0bf6145abf687385947599a62b8abdd298357c5882e267113615574e755

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

# encoding: utf-8

module Axiom
  class Function
    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

        module Methods

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

        end # module Methods
      end # class NoMatch
    end # class Predicate
  end # class Function
end # module Axiom

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
axiom-0.2.0 lib/axiom/function/predicate/no_match.rb
axiom-0.1.1 lib/axiom/function/predicate/no_match.rb
axiom-0.1.0 lib/axiom/function/predicate/no_match.rb