Class: Dir
- Inherits:
-
Object
- Object
- Dir
- Defined in:
- lib/sprout/dir.rb
Class Method Summary (collapse)
-
+ (Boolean) empty?(path)
Return true if the provided path has no children.
Instance Method Summary (collapse)
-
- (Boolean) empty?
Return true if the directory has no children.
Class Method Details
+ (Boolean) empty?(path)
Return true if the provided path has no children.
Code found here: www.ruby-forum.com/topic/84762
19 20 21 |
# File 'lib/sprout/dir.rb', line 19 def self.empty? path new(path).empty? end |
Instance Method Details
- (Boolean) empty?
Return true if the directory has no children.
Code found here: www.ruby-forum.com/topic/84762
8 9 10 11 12 13 |
# File 'lib/sprout/dir.rb', line 8 def empty? Dir.glob("#{ path }/*", File::FNM_DOTMATCH) do |e| return false unless %w( . .. ).include?(File::basename(e)) end return true end |