Class: RIEL::FileDirProcessor

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

Instance Method Summary collapse

Constructor Details

#initialize(args, filters = Array.new) ⇒ FileDirProcessor

Returns a new instance of FileDirProcessor.



34
35
36
37
38
39
# File 'lib/riel/fdprocessor.rb', line 34

def initialize args, filters = Array.new
  @filters = filters
  args.each do |arg|
    process Pathname.new arg
  end
end

Instance Method Details

#process(fd) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/riel/fdprocessor.rb', line 51

def process fd
  @filters.each do |filter| 
    return nil unless filter.match? fd
  end
  
  if fd.directory?
    process_directory fd
  elsif fd.file?
    process_file fd
  else
    process_unknown_type fd
  end
end

#process_directory(dir) ⇒ Object



44
45
46
47
48
49
# File 'lib/riel/fdprocessor.rb', line 44

def process_directory dir
  dir.children.sort.each do |fd|
    next if @filters && @filters.include?(fd.basename.to_s)
    process fd
  end
end

#process_file(file) ⇒ Object



41
42
# File 'lib/riel/fdprocessor.rb', line 41

def process_file file
end

#process_unknown_type(fd) ⇒ Object



65
66
# File 'lib/riel/fdprocessor.rb', line 65

def process_unknown_type fd
end