Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

File::Stat#world_readable?

() -> ::Integer?
stat.world_readable? → integer or nil

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"
See also #uid #world_writable? #symlink? #writable? also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0