Sha256: 9e29a1b36d3c941563366a1668645b9cd094189b2ec7c4312b62cbeda346ebac
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Matchi # *Regular expressions* matcher. class Match # Initialize the matcher with an instance of Regexp. # # @example # require "matchi/match" # # Matchi::Match.new(/^foo$/) # # @param expected [#match] A regular expression. def initialize(expected) @expected = expected end # Boolean comparison between the actual value and the expected value. # # @example # require "matchi/match" # # matcher = Matchi::Match.new(/^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. def matches?(*, **) @expected.match?(yield) end # A string containing a human-readable representation of the matcher. def inspect "#{self.class}(#{@expected.inspect})" end # Returns a string representing the matcher. def to_s "match #{@expected.inspect}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
matchi-3.0.0 | lib/matchi/match.rb |