Sha256: 9b02fd2caee784f849c1ecc2cb86681f8dce2de9b17c1605ab03e05143d1960d

Contents?: true

Size: 989 Bytes

Versions: 5

Compression:

Stored size: 989 Bytes

Contents

module Mutant
  # Abstract matcher to find ASTs to mutate
  class Matcher
    include Adamantium::Flat, Enumerable, AbstractType
    extend DescendantsTracker

    # Enumerate subjects
    #
    # @api private
    #
    # @return [undefined]
    #
    abstract_method :each

    # Return identification
    #
    # @return [String
    #
    # @api private
    #
    abstract_method :identification

    # Return matcher
    #
    # @param [String] input
    #
    # @return [nil]
    #   returns nil as default implementation
    #
    # @api private
    #
    def self.parse(input)
      nil
    end

    # Return match from string
    #
    # @param [String] input
    #
    # @return [Matcher]
    #   returns matcher input if successful
    #
    # @return [nil]
    #   returns nil otherwise
    #
    def self.from_string(input)
      descendants.each do |descendant|
        matcher = descendant.parse(input)
        return matcher if matcher
      end

      nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mutant-0.2.4 lib/mutant/matcher.rb
mutant-0.2.3 lib/mutant/matcher.rb
mutant-0.2.2 lib/mutant/matcher.rb
mutant-0.2.1 lib/mutant/matcher.rb
mutant-0.2.0 lib/mutant/matcher.rb