Class: DirectoryWatcher::Scan

Inherits:
Object
  • Object
show all
Defined in:
lib/directory_watcher/scan.rb

Overview

A Scan is the scan of a full directory structure with the ability to iterate over the results, or return them as a full dataset

results = Scan.new( globs ).run

Instance Method Summary collapse

Constructor Details

#initialize(globs = Array.new) ⇒ Scan

Returns a new instance of Scan.



8
9
10
11
# File 'lib/directory_watcher/scan.rb', line 8

def initialize( globs = Array.new )
  @globs = [ globs ].flatten
  @results = Array.new
end

Instance Method Details

#resultsObject

Return the results of the scan. If the scan has not been run yet, then run it



23
24
25
26
# File 'lib/directory_watcher/scan.rb', line 23

def results
  @results = collect_all_stats if @results.empty?
  return @results
end

#runObject

Run the entire scan and collect all the results. The Scan will only ever be run once.

Return the array of FileStat results



17
18
19
# File 'lib/directory_watcher/scan.rb', line 17

def run
  results
end