Class: CleanUp::Conditions::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/clean_up/conditions/pattern.rb

Instance Method Summary collapse

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

Returns:

  • (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