End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
File::Stat#world_readable?
stat.world_readable? → integer or nil
file.c
View on GitHub ↗
static VALUE
rb_stat_wr(VALUE obj)
{
#ifdef S_IROTH
struct stat *st = get_stat(obj);
if ((st->st_mode & (S_IROTH)) == S_IROTH) {
return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
}
else {
return Qnil;
}
#endif
}
If stat is readable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).
Example
m = File.stat("/etc/passwd").world_readable? #=> 420 sprintf("%o", m) #=> "644"