Class: Utils::Patterns::Pattern
Direct Known Subclasses
Instance Attribute Summary collapse
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Pattern
constructor
A new instance of Pattern.
- #method_missing(*a, &b) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Pattern
Returns a new instance of Pattern.
4 5 6 7 8 9 10 |
# File 'lib/utils/patterns.rb', line 4 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*a, &b) ⇒ Object
14 15 16 17 18 |
# File 'lib/utils/patterns.rb', line 14 def method_missing(*a, &b) @matcher.__send__(*a, &b) rescue ArgumentError => e raise e unless e..include?('invalid byte sequence in UTF-8') end |
Instance Attribute Details
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
12 13 14 |
# File 'lib/utils/patterns.rb', line 12 def matcher @matcher end |