Sha256: 2d7d85b28b4f20c77d94b3e30ffda9f1646871a07daaeb6c825a785aa02f9579

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

# encoding: utf-8

module Veritas
  class Function
    class Predicate

      # A predicate representing a regexp match between operands
      class Match < Predicate
        include Comparable

        # Evaluate the left and right value to see if they match
        #
        # @example
        #   matches = Match.call(left, right)
        #
        # @return [Boolean]
        #
        # @api public
        def self.call(*)
          !!super
        end

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

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

        module Methods

          # Compare the left to see if it matches the right
          #
          # @example
          #   match = expression.match(regexp)
          #
          # @param [Function] other
          #
          # @return [Match]
          #
          # @api public
          def match(regexp)
            Match.new(self, regexp)
          end

        end # module Methods
      end # class Match
    end # class Predicate
  end # class Function
end # module Veritas

Version data entries

2 entries across 2 versions & 1 rubygems

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