Class: Omnizip::Extraction::PatternMatcher
- Inherits:
-
Object
- Object
- Omnizip::Extraction::PatternMatcher
- Defined in:
- lib/omnizip/extraction/pattern_matcher.rb
Overview
Coordinates pattern matching across different pattern types
Automatically detects pattern type and delegates to appropriate pattern implementation (glob, regex, or predicate).
Instance Attribute Summary collapse
-
#pattern ⇒ GlobPattern, ...
readonly
Get the underlying pattern object.
Instance Method Summary collapse
-
#initialize(pattern) ⇒ PatternMatcher
constructor
Initialize a new pattern matcher.
-
#match?(filename) ⇒ Boolean
Check if a filename matches the pattern.
-
#match_all(filenames) ⇒ Array<String>
Match against multiple filenames.
-
#to_s ⇒ String
Convert pattern to string.
Constructor Details
#initialize(pattern) ⇒ PatternMatcher
Initialize a new pattern matcher
13 14 15 |
# File 'lib/omnizip/extraction/pattern_matcher.rb', line 13 def initialize(pattern) @pattern = build_pattern(pattern) end |
Instance Attribute Details
#pattern ⇒ GlobPattern, ... (readonly)
Get the underlying pattern object
36 37 38 |
# File 'lib/omnizip/extraction/pattern_matcher.rb', line 36 def pattern @pattern end |
Instance Method Details
#match?(filename) ⇒ Boolean
Check if a filename matches the pattern
21 22 23 |
# File 'lib/omnizip/extraction/pattern_matcher.rb', line 21 def match?(filename) @pattern.match?(filename) end |
#match_all(filenames) ⇒ Array<String>
Match against multiple filenames
29 30 31 |
# File 'lib/omnizip/extraction/pattern_matcher.rb', line 29 def match_all(filenames) filenames.select { |filename| match?(filename) } end |
#to_s ⇒ String
Convert pattern to string
41 42 43 |
# File 'lib/omnizip/extraction/pattern_matcher.rb', line 41 def to_s @pattern.to_s end |