Class: Ramcrest::Matcher::MatchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/ramcrest/matcher.rb

Constant Summary collapse

SUCCESS =
MatchResult.new(true)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (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

Returns:

  • (Boolean)


53
54
55
# File 'lib/ramcrest/matcher.rb', line 53

def matched?
  @matched
end

#negateObject



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