Module: Figs::DirectoryFlattener
- Extended by:
- DirectoryFlattener
- Included in:
- DirectoryFlattener
- Defined in:
- lib/figs/directory_flattener.rb
Overview
A tool to get filenames from a directory.
Instance Method Summary collapse
-
#flattened_filenames(filenames) ⇒ Object
Creates an array consisting of only files contained in a directory and its subdirectories.
Instance Method Details
#flattened_filenames(filenames) ⇒ Object
Creates an array consisting of only files contained in a directory and its subdirectories.
Expects an array of filenames or dirnames or a combination of both.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/figs/directory_flattener.rb', line 14 def flattened_filenames(filenames) # Expect an array of filenames return otherwise return filenames if !filenames.is_a?(Array) # Iterate through array filenames.map! do |filename| # Flatten if its a file, flatten if a dir. Dir.exists?(filename) ? directory_to_filenames(filename) : filename end # Flattern the array and remove all nils filenames.flatten.compact end |