free_mutant/lib/mutant/matcher/chain.rb
Markus Schirp dfcabdc279 Fix style of YARD @return tag description
Before there was lots of redundant information. These comments where
very old and my current YARD doc style changed in the meantime. Keep it
DRY.
2013-09-11 20:50:23 +02:00

47 lines
841 B
Ruby

# encoding: utf-8
module Mutant
class Matcher
# A chain of matchers
class Chain < self
include Concord::Public.new(:matchers)
# Enumerate subjects
#
# @return [Enumerator<Subject]
# if no block given
#
# @return [self]
# otherwise
#
# @api private
#
def each(&block)
return to_enum unless block_given?
matchers.each do |matcher|
matcher.each(&block)
end
self
end
# Build matcher chain
#
# @param [Enumerable<Matcher>] matchers
#
# @return [Matcher]
#
# @api private
#
def self.build(matchers)
if matchers.length == 1
return matchers.first
end
new(matchers)
end
end # Chain
end # Matcher
end # Mutant