Class: Mutant::Matcher::Chain

Inherits:
Mutant::Matcher show all
Defined in:
lib/mutant/matcher/chain.rb

Overview

A chain of matchers

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mutant::Matcher

from_string, #identification, parse

Instance Attribute Details

#matchersEnumerable<Chain> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the chain of matchers

Returns:



33
34
35
# File 'lib/mutant/matcher/chain.rb', line 33

def matchers
  @matchers
end

Class Method Details

.build(matchers) ⇒ Matcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build matcher chain

Parameters:

Returns:



43
44
45
46
47
48
49
# File 'lib/mutant/matcher/chain.rb', line 43

def self.build(matchers)
  if matchers.length == 1
    return matchers.first
  end

  new(matchers)
end

Instance Method Details

#each(&block) ⇒ Enumerator<Subject] returns subject enumerator if no block given, self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enumerate subjects

Returns:

  • (Enumerator<Subject] returns subject enumerator if no block given)

    Enumerator<Subject] returns subject enumerator if no block given

  • (self)

    returnns self otherwise



17
18
19
20
21
22
23
24
25
# File 'lib/mutant/matcher/chain.rb', line 17

def each(&block)
  return to_enum unless block_given?

  matchers.each do |matcher|
    matcher.each(&block)
  end

  self
end