class Matchi::Match
*Regular expressions* matcher.
Attributes
expected[R]
@return [#match] A regular expression.
Public Class Methods
new(expected)
click to toggle source
Initialize the matcher with an instance of Regexp.
@example
require "matchi/match" Matchi::Match.new(/^foo$/)
@param expected [#match] A regular expression.
# File lib/matchi/match.rb, line 17 def initialize(expected) @expected = expected end
Public Instance Methods
inspect()
click to toggle source
A string containing a human-readable representation of the matcher.
# File lib/matchi/match.rb, line 40 def inspect "#{self.class}(#{expected.inspect})" end
matches?() { || ... }
click to toggle source
Boolean comparison between the actual value and the expected value.
@example
require "matchi/match" matcher = Matchi::Match.new(/^foo$/) matcher.expected # => /^foo$/ matcher.matches? { "foo" } # => true
@yieldreturn [#object_id] The actual value to compare to the expected
one.
@return [Boolean] Comparison between actual and expected values.
# File lib/matchi/match.rb, line 35 def matches? expected.match?(yield) end
to_s()
click to toggle source
Returns a string representing the matcher.
# File lib/matchi/match.rb, line 45 def to_s "match #{expected.inspect}" end