Sha256: 93083e3d19840a2e4e7680c23044b7dc7fd0d9bcdbcd118953ef690cc1c32e6d
Contents?: true
Size: 767 Bytes
Versions: 17
Compression:
Stored size: 767 Bytes
Contents
# frozen_string_literal: true module EacRubyUtils # The `Wildcards` class provides pattern matching with wildcards using regular expressions. class Wildcards # Initializes a new instance of the `Wildcards` class with the specified pattern. # # @param pattern [String] The pattern to match against. def initialize(pattern) @pattern = pattern end # Matches the given string against the pattern. # # @param string [String] The string to match. # @return [Boolean] Returns `true` if the string matches the pattern, otherwise `false`. delegate :match?, to: :regex private # @return [Regexp] def regex ::Regexp.new("^#{::Regexp.escape(@pattern).gsub('\*', '.*').gsub('\?', '.?')}$") end end end
Version data entries
17 entries across 17 versions & 2 rubygems