Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

File::Stat#readable?

() -> bool
readable? → true or false

Returns whether the entry represented by self exists and is readable by the owner and group of the current process; see Permissions:

Example
path = '/tmp/secret.txt'
File.write(path, 'foo')
File.stat(path).readable? # => true
File.chmod(0o000, path)
File.stat(path).readable? # => false
File.delete(path)         # Clean up.
See also #rdev_minor #readable_real? #rdev_major #setgid? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0