Sha256: ab10c5d120f3ba373d99ad6a794ddc3127e39fdf95abf3320b270a18faeab309

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

# encoding: utf-8

module Axiom
  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 ? true : false
        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 [Regexp] regexp
          #
          # @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 Axiom

Version data entries

3 entries across 3 versions & 1 rubygems

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