Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#writable?
() -> bool
writable? => true or false
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 2709
def writable?() FileTest.writable?(@path) end
Returns whether entry at the path in self exists and is writable by the effective owner and group of the current process:
Example
pn = Pathname('/tmp/secret.txt') pn.writable? # => false # Non-existent. pn.write('foo') # Create the file. pn.writable? # => true # Writable. pn.chmod(0o000) # Make non-writable. pn.writable? # => false # Not writable. pn.delete # Clean up. Pathname('/etc/').writable? # => false # Directory.
Note that filesystem security features may cause this method to return true even when the entry is not writable by the effective owner and group.
See also
#world_writable?
#writable_real?
#world_readable?
#write
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0