Class: Matchi::Match
- Inherits:
-
Object
- Object
- Matchi::Match
- Defined in:
- lib/matchi/match.rb
Overview
*Regular expressions* matcher.
Instance Method Summary collapse
-
#initialize(expected) ⇒ Match
constructor
Initialize the matcher with an instance of Regexp.
-
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
-
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
-
#to_s ⇒ Object
Returns a string representing the matcher.
Constructor Details
#initialize(expected) ⇒ Match
Initialize the matcher with an instance of Regexp.
14 15 16 |
# File 'lib/matchi/match.rb', line 14 def initialize(expected) @expected = expected end |
Instance Method Details
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
35 36 37 |
# File 'lib/matchi/match.rb', line 35 def inspect "#{self.class}(#{@expected.inspect})" end |
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
30 31 32 |
# File 'lib/matchi/match.rb', line 30 def matches?(*, **) @expected.match?(yield) end |
#to_s ⇒ Object
Returns a string representing the matcher.
40 41 42 |
# File 'lib/matchi/match.rb', line 40 def to_s "match #{@expected.inspect}" end |