Class: DirectoryProcessor
- Inherits:
-
Object
- Object
- DirectoryProcessor
- Defined in:
- lib/rforward/directory_processor.rb
Instance Attribute Summary collapse
-
#ext ⇒ Object
Returns the value of attribute ext.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path, ext) ⇒ DirectoryProcessor
constructor
A new instance of DirectoryProcessor.
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
#ext ⇒ Object
Returns the value of attribute ext.
4 5 6 |
# File 'lib/rforward/directory_processor.rb', line 4 def ext @ext end |
#path ⇒ Object
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
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
#call ⇒ Object
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 |