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

() -> bool
owned? → true or false

Returns whether the entry at the path represented by self exists and is owned by the user of the current process:

Example
pn = Pathname('doc/t.tmp')
pn.write('foo')
pn.owned?               # => true
pn.delete               # Clean up.
pn = Pathname('doc/tmp')
pn.mkdir
pn.owned?               # => true
pn.rmdir                # Clean up.
Pathname('/etc').owned? # => false
See also #opendir #parent #open #pipe? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0