Sha256: 809c43d657aaa893a39c9f9d966f119cd5b74b1134f011b1426171d41521a511
Contents?: true
Size: 724 Bytes
Versions: 4
Compression:
Stored size: 724 Bytes
Contents
module Matchi # **Regular expressions** matcher. class Match < BasicObject # Initialize the matcher with an instance of Regexp. # # @example Username matcher # Matchi::Match.new(/^[a-z0-9_-]{3,16}$/) # # @param expected [#match] A regular expression. def initialize(expected) @expected = expected end # @example Is it matching /^foo$/ regex? # match = Matchi::Match.new(/^foo$/) # match.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).nil?.equal?(false) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
matchi-0.0.9 | lib/matchi/match.rb |
matchi-0.0.8 | lib/matchi/match.rb |
matchi-0.0.7 | lib/matchi/match.rb |
matchi-0.0.6 | lib/matchi/match.rb |