class Utils::Patterns::Pattern
@abstract
configuration and delegates specific matching behavior to subclasses.
character set filtering and case sensitivity options. It handles the core
strategies, providing common functionality for initializing patterns with
This class serves as the foundation for various pattern matching
Base class for pattern matching implementations.
def initialize(opts = {})
-
(ArgumentError)- if the pattern option is not provided
Options Hash:
(**opts)-
:pattern(String) -- the pattern string to be used for matching -
:icase(TrueClass, FalseClass) -- whether the pattern matching should be case sensitive -
:cset(String) -- the character set to filter pattern characters against
Parameters:
-
opts(Hash) -- a hash containing the pattern configuration options
def initialize(opts = {}) @cset = opts[:cset] @icase = opts[:icase] @pattern = opts[:pattern] or raise ArgumentError, "pattern option required" @pattern = @pattern.gsub(/[^#{@cset}]/, '') if @cset end
def method_missing(*a, &b)
-
(Object)- the result of the delegated method call on the matcher
Parameters:
-
b(Proc) -- the block passed to the missing method -
a(Array) -- the arguments passed to the missing method
def method_missing(*a, &b) @matcher.__send__(*a, &b) rescue ArgumentError => e raise e unless e.message.include?('invalid byte sequence in UTF-8') end