Module: Opener::BuildTools::Files
- Defined in:
- lib/opener/build-tools/files.rb
Overview
Module that contains various helper methods that makes it easier to work with collections of files and iterate over them.
Class Method Summary collapse
-
.directory_contents(directory) ⇒ Object
Returns an Array containing the contents of a given directory, excluding ‘.’ and ‘..’.
-
.each_file(directory) {|String| ... } ⇒ Object
Calls the supplied block for each file in the given directory, ignoring ‘.’ and ‘..’.
Class Method Details
.directory_contents(directory) ⇒ Object
Returns an Array containing the contents of a given directory, excluding ‘.’ and ‘..’.
16 17 18 |
# File 'lib/opener/build-tools/files.rb', line 16 def directory_contents(directory) return Dir.glob(File.join(directory, '*')) end |
.each_file(directory) {|String| ... } ⇒ Object
Calls the supplied block for each file in the given directory, ignoring ‘.’ and ‘..’.
27 28 29 30 31 |
# File 'lib/opener/build-tools/files.rb', line 27 def each_file(directory) directory_contents(directory).each do |path| yield path end end |