Class: DirectoryProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/rforward/directory_processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, ext) ⇒ DirectoryProcessor

Returns a new instance of DirectoryProcessor.



6
7
8
# File 'lib/rforward/directory_processor.rb', line 6

def initialize path, ext
  @path, @ext = path, ext
end

Instance Attribute Details

#extObject

Returns the value of attribute ext.



4
5
6
# File 'lib/rforward/directory_processor.rb', line 4

def ext
  @ext
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/rforward/directory_processor.rb', line 4

def path
  @path
end

Class Method Details

.call(path, ext) ⇒ Object

Raises:



19
20
21
22
23
24
# File 'lib/rforward/directory_processor.rb', line 19

def self.call path, ext
  path = Pathname.new path
  raise WrongPathEx, path unless path.directory? && path.exist?
  processor = DirectoryProcessor.new path.to_path, ext
  processor.call
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
# File 'lib/rforward/directory_processor.rb', line 10

def call
  files_arr = Dir["#{path}/**#{ext}"]
  files_arr = files_arr.select { |file| File.file? file } 
  Stat.instance.files_total = files_arr.count
  files_arr.each do |filepath|
    FileProcessor.call filepath
  end
end