Class: Cleaner::FileFilter
- Inherits:
-
Object
- Object
- Cleaner::FileFilter
- Defined in:
- lib/cleaner/file_filter.rb
Constant Summary collapse
- CONDITIONS =
[:after, :if, :smaller_than, :bigger_than]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #filterize ⇒ Object
-
#initialize(options = {}) ⇒ FileFilter
constructor
A new instance of FileFilter.
- #search_pattern ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ FileFilter
Returns a new instance of FileFilter.
7 8 9 10 |
# File 'lib/cleaner/file_filter.rb', line 7 def initialize( = {}) @options = @pattern = [:pattern] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/cleaner/file_filter.rb', line 5 def @options end |
Instance Method Details
#filterize ⇒ Object
12 13 14 15 |
# File 'lib/cleaner/file_filter.rb', line 12 def filterize paths = filter_by_name conditions_provided? ? filter_by_conditions(paths) : paths end |
#search_pattern ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/cleaner/file_filter.rb', line 17 def search_pattern case @pattern when NilClass; "#{path}/*" when String; "#{path}/#{@pattern}" when Symbol; "#{path}/*.#{@pattern}" when Array; @pattern.map { |ext| "#{path}/*.#{ext}" } end end |