End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
File::Stat#directory?
File.directory?(path) → true or false
file.c
View on GitHub ↗
static VALUE
rb_stat_d(VALUE obj)
{
if (S_ISDIR(get_stat(obj)->st_mode)) return Qtrue;
return Qfalse;
}
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
#dev_minor
#executable?
#dev_major
#executable_real?
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0