Class: CommandT::Scanner
- Inherits:
-
Object
- Object
- CommandT::Scanner
- Defined in:
- lib/command_t/scanner.rb
Overview
Reads the current directory recursively for the paths to all regular files.
Defined Under Namespace
Classes: FileLimitExceeded
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(path = Dir.pwd, options = {}) ⇒ Scanner
constructor
A new instance of Scanner.
- #path=(str) ⇒ Object
- #paths ⇒ Object
Constructor Details
#initialize(path = Dir.pwd, options = {}) ⇒ Scanner
Returns a new instance of Scanner.
29 30 31 32 33 34 |
# File 'lib/command_t/scanner.rb', line 29 def initialize path = Dir.pwd, = {} @path = path @max_depth = [:max_depth] || 15 @max_files = [:max_files] || 10_000 @scan_dot_directories = [:scan_dot_directories] || false end |
Instance Method Details
#flush ⇒ Object
49 50 51 |
# File 'lib/command_t/scanner.rb', line 49 def flush @paths = nil end |
#path=(str) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/command_t/scanner.rb', line 53 def path= str if @path != str @path = str flush end end |
#paths ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/command_t/scanner.rb', line 36 def paths return @paths unless @paths.nil? begin @paths = [] @depth = 0 @files = 0 @prefix_len = @path.chomp('/').length add_paths_for_directory @path, @paths rescue FileLimitExceeded end @paths end |