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.1.18.pre lib/sprout/dir.rb
sprout-1.1.17.pre lib/sprout/dir.rb
sprout-1.1.16.pre lib/sprout/dir.rb
sprout-1.1.15.pre lib/sprout/dir.rb
sprout-1.1.14.pre lib/sprout/dir.rb
sprout-1.1.13.pre lib/sprout/dir.rb
sprout-1.1.11.pre lib/sprout/dir.rb
sprout-1.1.10.pre lib/sprout/dir.rb
sprout-1.1.7.pre lib/sprout/dir.rb
sprout-1.1.5.pre lib/sprout/dir.rb
sprout-1.1.4.pre lib/sprout/dir.rb
sprout-1.1.3.pre lib/sprout/dir.rb
sprout-1.1.2.pre lib/sprout/dir.rb
sprout-1.0.35.pre lib/sprout/dir.rb
sprout-1.0.32.pre lib/sprout/dir.rb
sprout-1.0.31.pre lib/sprout/dir.rb
sprout-1.0.29.pre lib/sprout/dir.rb
sprout-1.0.26.pre lib/sprout/dir.rb
sprout-1.0.25.pre lib/sprout/dir.rb
sprout-1.0.24.pre lib/sprout/dir.rb