Class: Omnizip::Extraction::GlobPattern
- Inherits:
-
Object
- Object
- Omnizip::Extraction::GlobPattern
- Defined in:
- lib/omnizip/extraction/glob_pattern.rb
Overview
Implements glob pattern matching for file paths
Supports:
-
-
- Match any characters except /
-
- ** - Match any characters including /
- ? - Match single character
- [abc] - Character class
- [!abc] - Negated character class
- a,b,c - Alternation (brace expansion)
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern) ⇒ GlobPattern
constructor
Initialize a new glob pattern.
-
#match?(filename) ⇒ Boolean
Check if a filename matches the pattern.
-
#to_s ⇒ String
Convert pattern to string.
Constructor Details
#initialize(pattern) ⇒ GlobPattern
Initialize a new glob pattern
20 21 22 23 |
# File 'lib/omnizip/extraction/glob_pattern.rb', line 20 def initialize(pattern) @pattern = pattern.to_s @regex = compile_pattern end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
15 16 17 |
# File 'lib/omnizip/extraction/glob_pattern.rb', line 15 def pattern @pattern end |
Instance Method Details
#match?(filename) ⇒ Boolean
Check if a filename matches the pattern
29 30 31 |
# File 'lib/omnizip/extraction/glob_pattern.rb', line 29 def match?(filename) @regex.match?(filename.to_s) end |
#to_s ⇒ String
Convert pattern to string
36 37 38 |
# File 'lib/omnizip/extraction/glob_pattern.rb', line 36 def to_s @pattern end |