Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Pathname#empty?

DZone's Guide to

Pathname#empty?

·
Free Resource
This should just be part of Pathname.


class Pathname
  # Returns true if the Pathname is a directory and contains no files or directories.
  def empty?
    self.directory? && self.entries.find_all {|f| f.to_s !~ /^\.\.?$/ }.empty? 
  end
end
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}