Class: UnifiedMatchers::MatcherResults

Inherits:
Object
  • Object
show all
Defined in:
lib/unified_matchers/matcher_results.rb

Instance Method Summary collapse

Constructor Details

#initialize(*matcher_results) ⇒ MatcherResults

Returns a new instance of MatcherResults.



10
11
12
# File 'lib/unified_matchers/matcher_results.rb', line 10

def initialize *matcher_results
  @elements = matcher_results.flatten
end

Instance Method Details

#<<(result) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/unified_matchers/matcher_results.rb', line 36

def << result
  if result.respond_to? :each
    result.each { |x| @elements << x }
  else
    @elements << result
  end
end

#each(&block) ⇒ Object



22
23
24
# File 'lib/unified_matchers/matcher_results.rb', line 22

def each &block
  @elements.each(&block)
end

#failure?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/unified_matchers/matcher_results.rb', line 18

def failure?
  @elements.any? { |x| x.failure? }
end

#firstObject



26
27
28
# File 'lib/unified_matchers/matcher_results.rb', line 26

def first
  @elements.first
end

#success?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/unified_matchers/matcher_results.rb', line 14

def success?
  @elements.all? { |x| x.success? }
end

#to_sObject



30
31
32
33
34
# File 'lib/unified_matchers/matcher_results.rb', line 30

def to_s
  s = ''
  each { |x| s << x.to_s << "\n" }
  s
end