Sha256: da120b6b7a6d9bc5116f72e51f0228cd5f42ca10ccefd592634a9c10daeb1cf9

Contents?: true

Size: 473 Bytes

Versions: 39

Compression:

Stored size: 473 Bytes

Contents

class Dir

  ##
  # Return true if the directory has no children.
  # 
  # Code found here: http://www.ruby-forum.com/topic/84762
  def empty?
    Dir.glob("#{ path }/*", File::FNM_DOTMATCH) do |e|
      return false unless %w( . .. ).include?(File::basename(e))
    end
    return true
  end

  ##
  # Return true if the provided path has no children.
  # 
  # Code found here: http://www.ruby-forum.com/topic/84762
  def self.empty? path
    new(path).empty?
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
sprout-1.0.23.pre lib/sprout/dir.rb
sprout-1.0.22.pre lib/sprout/dir.rb
sprout-1.0.20.pre lib/sprout/dir.rb
sprout-1.0.19.pre lib/sprout/dir.rb
sprout-1.0.18.pre lib/sprout/dir.rb
sprout-1.0.17.pre lib/sprout/dir.rb
sprout-1.0.16.pre lib/sprout/dir.rb
sprout-1.0.15.pre lib/sprout/dir.rb
sprout-1.0.14.pre lib/sprout/dir.rb
sprout-1.0.13.pre lib/sprout/dir.rb
sprout-1.0.11.pre lib/sprout/dir.rb
sprout-1.0.9.pre lib/sprout/dir.rb
sprout-1.0.8.pre lib/sprout/dir.rb
sprout-1.0.5.pre lib/sprout/dir.rb
sprout-1.0.4.pre lib/sprout/dir.rb
sprout-1.0.3.pre lib/sprout/dir.rb
sprout-1.0.2.pre lib/sprout/dir.rb
sprout-1.0.1.pre lib/sprout/dir.rb
sprout-1.0.0.pre lib/sprout/dir.rb