class HwCheker::HomeWorkChecker::FileScan

Attributes

files[R]

Public Class Methods

new(work_path) click to toggle source
# File lib/hw_cheker/file_scan.rb, line 5
def initialize(work_path)
  @work_path, @files = work_path, []
  Dir::foreach(@work_path) do |p|
    if File::file?("#{@work_path}/#{p}") && FILE_TYPES.include?(File::extname p) && !exist_xml?(p)
      @files << p
    end
  end
end

Public Instance Methods

each() { |name, type| ... } click to toggle source
# File lib/hw_cheker/file_scan.rb, line 14
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

Private Instance Methods

exist_xml?(archive_name) click to toggle source
# File lib/hw_cheker/file_scan.rb, line 28
def exist_xml?(archive_name)
  temp = archive_name.chomp(File::extname archive_name)
  File::exist? "#{@work_path}/#{temp}.xml"
end