Skip to content
instance method

FileTest#directory?

(::path | ::io file_name) -> 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 #chardev? #empty? #blockdev? #executable? also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0