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#world_readable?

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

If the entry at the path in self exists and is readable by others, returns the integer permissions for the entry; otherwise, returns nil:

Example
pn = Pathname('/tmp/t.tmp')
pn.world_readable?                    # => nil    # Does not exist.
pn.write('foo')                                   # Create file.
pn.world_readable?.to_s(8)            # => "664"  # World-readable.
pn.chmod(0o000)                                   # Change to unreadable.
pn.world_readable?                    # => nil    # Not readable.
pn.delete                                         # Clean up.
Pathname('.').world_readable?.to_s(8) # => "775"  # Directory.
See also #utime #world_writable? #unlink #writable? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0