Skip to content
class method

File.directory?

(::string | ::_ToPath | ::IO path) -> bool
File.directory?(path) → true or false

With string object given, returns true if path is a string path leading to a directory, or to a symbolic link to a directory; false otherwise:

Example
File.directory?('.')              # => true
File.directory?('foo')            # => false
File.symlink('.', 'dirlink')      # => 0
File.directory?('dirlink')        # => true
File.symlink('t,txt', 'filelink') # => 0
File.directory?('filelink')       # => false

Argument path can be an IO object.

See also .delete .dirname .ctime .empty? also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0