Class: RIEL::FileDirFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/riel/fdprocessor.rb

Overview

File and directory processor, with filtering.

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ FileDirFilter

Returns a new instance of FileDirFilter.



8
9
10
11
12
13
14
# File 'lib/riel/fdprocessor.rb', line 8

def initialize args
  @dirsonly = args[:dirsonly]
  @filesonly = args[:filesonly]
  @basename = args[:basename]
  @dirname = args[:dirname]
  @extname = args[:extname]
end

Instance Method Details

#match?(fd) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/riel/fdprocessor.rb', line 16

def match? fd
  if @dirsonly && !fd.directory?
    false
  elsif @filesonly && !fd.file?
    false
  elsif @basename && @basename != fd.basename.to_s
    false
  elsif @dirname && @dirname != fd.parent.to_s
    false
  elsif @extname && @extname != fd.extname
    false
  else
    true
  end
end