Class: CleanUp::Conditions::Pattern
- Inherits:
-
Object
- Object
- CleanUp::Conditions::Pattern
- Defined in:
- lib/clean_up/conditions/pattern.rb
Instance Method Summary collapse
-
#initialize(*value) ⇒ Pattern
constructor
A new instance of Pattern.
- #match?(file) ⇒ Boolean
Constructor Details
#initialize(*value) ⇒ Pattern
Returns a new instance of Pattern.
4 5 6 |
# File 'lib/clean_up/conditions/pattern.rb', line 4 def initialize(*value) @pattern = value.map { |regexp| Regexp.new(regexp) } end |
Instance Method Details
#match?(file) ⇒ Boolean
8 9 10 |
# File 'lib/clean_up/conditions/pattern.rb', line 8 def match?(file) @pattern.any? { |regexp| regexp.match(File.basename(file, '.*')) } end |