Sha256: cbfd94ec9179ea00433802d442e8395abdd0a4d33c381290ee2b50a63f7737f2

Contents?: true

Size: 1014 Bytes

Versions: 13

Compression:

Stored size: 1014 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
    #
    # @api private
    #
    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

13 entries across 13 versions & 1 rubygems

Version Path
mutant-0.2.20 lib/mutant/matcher.rb
mutant-0.2.17 lib/mutant/matcher.rb
mutant-0.2.16 lib/mutant/matcher.rb
mutant-0.2.15 lib/mutant/matcher.rb
mutant-0.2.14 lib/mutant/matcher.rb
mutant-0.2.13 lib/mutant/matcher.rb
mutant-0.2.12 lib/mutant/matcher.rb
mutant-0.2.11 lib/mutant/matcher.rb
mutant-0.2.9 lib/mutant/matcher.rb
mutant-0.2.8 lib/mutant/matcher.rb
mutant-0.2.7 lib/mutant/matcher.rb
mutant-0.2.6 lib/mutant/matcher.rb
mutant-0.2.5 lib/mutant/matcher.rb