Class: HwCheker::HomeWorkChecker::FileScan

Inherits:
Object
  • Object
show all
Defined in:
lib/hw_cheker/file_scan.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work_path) ⇒ FileScan

Returns a new instance of FileScan.



5
6
7
8
9
10
11
12
# 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

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



4
5
6
# File 'lib/hw_cheker/file_scan.rb', line 4

def files
  @files
end

Instance Method Details

#eachObject



14
15
16
17
18
19
20
21
22
23
24
25
# 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