Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
File::Stat#file?
() -> bool
file? → true or false
file.c
View on GitHub ↗
static VALUE
rb_stat_f(VALUE obj)
{
if (S_ISREG(get_stat(obj)->ST_(mode))) return Qtrue;
return Qfalse;
}
Returns whether self represents a filesystem entry that exists and is a regular file; see File::Stat.ftype:
Example
File.stat('/etc/passwd').file? # => true File.stat('/etc').file? # => false