Class: HomeWorkChecker::FileScan
- Inherits:
-
Object
- Object
- HomeWorkChecker::FileScan
- Defined in:
- lib/hw_checker/file_scan.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(archive_path, result_path, tmp_path = '/tmp') ⇒ FileScan
constructor
A new instance of FileScan.
Constructor Details
#initialize(archive_path, result_path, tmp_path = '/tmp') ⇒ FileScan
Returns a new instance of FileScan.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/hw_checker/file_scan.rb', line 3 def initialize(archive_path, result_path, tmp_path = '/tmp') raise DirectoryExistError, "Directory '#{archive_path}' does not exist" unless Dir::exist?(archive_path) raise DirectoryExistError, "Directory '#{result_path}' does not exist" unless Dir::exist?(result_path) raise DirectoryExistError, "Directory '#{tmp_path}' does not exist" unless Dir::exist?(tmp_path) @archive_path, @result_path, @tmp_path, @files = archive_path, result_path, tmp_path, [] Dir.foreach(@archive_path) do |p| if File.file?("#{archive_path}/#{p}") && ARCHIVE_TYPES.include?(File.extname p) && !exist_xml?(p) @files << p end end end |
Instance Method Details
#each ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hw_checker/file_scan.rb', line 15 def each if block_given? i = 0 while i < @files.size type = File.extname(@files[i]) name = @files[i].chomp(type) yield(name, type) i += 1 end end @files end |