class File
Extend file class Collect files in directory recursively and return Array
Public Class Methods
collect_files(path)
click to toggle source
@param path [String] specified directory path for getting files underneath @returns [Array] list of file paths that exist recursively underneath a directory
# File lib/automation_object/helpers/file.rb, line 9 def collect_files(path) raise "Expecting path to exist, got #{path}" unless File.exist?(path) if File.directory?(path) @file_array = [] recursive_collection(path) else @file_array = [path] end @file_array end
Protected Class Methods
recursive_collection(path)
click to toggle source
Use for recursive collection of files @param path [String] specified directory path for getting files underneath
# File lib/automation_object/helpers/file.rb, line 26 def recursive_collection(path) Dir.foreach(path) do |item| next if item == '.' || item == '..' file_path = File.join(path, item.to_s) if File.directory?(file_path) recursive_collection(file_path) else @file_array.push(file_path) end end end