free_mutant/lib/mutant/matcher.rb
Dan Kubb 7293386c26 Add magic encoding header to all ruby files
* rubocop still warns about this on ruby 1.9.3, so it was fixed so
  it produces less output on travis.
2013-07-28 16:03:06 -07:00

62 lines
1.1 KiB
Ruby

# encoding: utf-8
module Mutant
# Abstract matcher to find subjects to mutate
class Matcher
include Adamantium::Flat, Enumerable, AbstractType
extend DescendantsTracker
# Enumerate subjects
#
# @param [Object] input
#
# @return [self]
# if block given
#
# @return [Enumerable<Subject>]
#
# @api private
#
def self.each(cache, input, &block)
return to_enum(__method__, cache, input) unless block_given?
build(cache, input).each(&block)
self
end
# Default matcher build implementation
#
# @param [Cache] cache
# @param [Object] input
#
# @return [undefined]
#
# @api private
#
def self.build(*arguments)
new(*arguments)
end
# Enumerate subjects
#
# @api private
#
# @return [self]
# if block given
#
# @return [Enumerabe<Subject>]
# otherwise
#
abstract_method :each
# Return identification
#
# @return [String
#
# @api private
#
abstract_method :identification
end # Matcher
end # Mutant