Class: Ramcrest::Matcher::MatchResult
- Inherits:
-
Object
- Object
- Ramcrest::Matcher::MatchResult
- Defined in:
- lib/ramcrest/matcher.rb
Constant Summary collapse
- SUCCESS =
MatchResult.new(true)
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Instance Method Summary collapse
- #and_also(&continue_block) ⇒ Object
-
#initialize(matched, description = nil) ⇒ MatchResult
constructor
A new instance of MatchResult.
- #matched? ⇒ Boolean
- #negate ⇒ Object
- #or_else(&mismatch_block) ⇒ Object
Constructor Details
#initialize(matched, description = nil) ⇒ MatchResult
Returns a new instance of MatchResult.
28 29 30 31 |
# File 'lib/ramcrest/matcher.rb', line 28 def initialize(matched, description = nil) @matched = matched @description = description end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
26 27 28 |
# File 'lib/ramcrest/matcher.rb', line 26 def description @description end |
Instance Method Details
#and_also(&continue_block) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/ramcrest/matcher.rb', line 45 def and_also(&continue_block) if matched? yield else self end end |
#matched? ⇒ Boolean
53 54 55 |
# File 'lib/ramcrest/matcher.rb', line 53 def matched? @matched end |
#negate ⇒ Object
33 34 35 |
# File 'lib/ramcrest/matcher.rb', line 33 def negate MatchResult.new(!@matched, @description) end |
#or_else(&mismatch_block) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/ramcrest/matcher.rb', line 37 def or_else(&mismatch_block) if matched? self else yield self end end |