Skip to content

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

instance method

Pathname#readable?

() -> bool
readable? → true or false

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

Example
pn = Pathname('/tmp/secret.txt')
pn.write('foo')
pn.readable?                 # => true
pn.chmod(0o000)
pn.readable?                 # => false
pn.delete                    # Clean up.
Pathname('nosuch').readable? # => false
See also #read #readable_real? #pipe? #readlines also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0