Class: Dir

Inherits:
Object
  • Object
show all
Defined in:
sprout/lib/sprout/dir.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) empty?(path)

Return true if the provided path has no children.

Code found here: www.ruby-forum.com/topic/84762

Returns:

  • (Boolean)


19
20
21
# File 'sprout/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

Returns:

  • (Boolean)


8
9
10
11
12
13
# File 'sprout/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