Class: UnifiedMatchers::MatcherResults
- Defined in:
- lib/unified_matchers/matcher_results.rb
Instance Method Summary collapse
- #<<(result) ⇒ Object
- #each(&block) ⇒ Object
- #failure? ⇒ Boolean
- #first ⇒ Object
-
#initialize(*matcher_results) ⇒ MatcherResults
constructor
A new instance of MatcherResults.
- #success? ⇒ Boolean
- #to_s ⇒ Object
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
18 19 20 |
# File 'lib/unified_matchers/matcher_results.rb', line 18 def failure? @elements.any? { |x| x.failure? } end |
#first ⇒ Object
26 27 28 |
# File 'lib/unified_matchers/matcher_results.rb', line 26 def first @elements.first end |
#success? ⇒ Boolean
14 15 16 |
# File 'lib/unified_matchers/matcher_results.rb', line 14 def success? @elements.all? { |x| x.success? } end |
#to_s ⇒ Object
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 |