From 8c82ca2c3f1e130f5adc6883873b3abd951a8ab3 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Thu, 15 Oct 2026 18:48:20 -0500 Subject: [PATCH] [DOC] Harmonize world_readable? methods --- file.c | 23 ++++++++++++----------- pathname_builtin.rb | 5 ++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/file.c b/file.c index 9da49f9d681..22f3ab88b2b 100644 --- a/file.c +++ b/file.c @@ -2421,9 +2421,9 @@ rb_file_readable_real_p(VALUE obj, VALUE fname) * call-seq: * File.world_readable?(object) -> integer or nil * - * If the the given `object` exists and is readable by others, - * returns the integer [permissions](rdoc-ref:file/filesystem_modes.md@Permissions) - * for the entry; + * Returns the integer [permissions](rdoc-ref:file/filesystem_modes.md@Permissions) + * for the given `object` + * if it exists and is readable by others; * otherwise, returns `nil`: * * ```ruby @@ -7517,22 +7517,23 @@ rb_stat_R(VALUE obj) * call-seq: * world_readable? -> integer or nil * - * If the entry in the [snapshot](rdoc-ref:File::Stat@Snapshot) - * in `self` exists and is readable by others, - * returns the integer [permissions](rdoc-ref:file/filesystem_modes.md@Permissions) - * for the entry; + * Returns the integer [permissions](rdoc-ref:file/filesystem_modes.md@Permissions) + * for the entry in the [snapshot](rdoc-ref:File::Stat@Snapshot) in `self` + * if those permissions allow reading by others; * otherwise, returns `nil`: * * ```ruby * filepath = '/tmp/t.tmp' * File.write(filepath, 'foo') # Create file. + * File.chmod(0o000, filepath) # Make file unreadable. * stat0 = File.stat(filepath) # Take snapshot. - * stat0.world_readable?.to_s(8) # => "664" # Snapshot shows world-readable. - * File.chmod(0o000, filepath) # Make unreadable. - * stat0.world_readable?.to_s(8) # => "664" # Snapshot not updated. + * stat0.world_readable? # => nil # Snapshot shows not world-readable. + * File.chmod(0o644, filepath) # Make file world-readable. + * stat0.world_readable? # => nil # Snapshot not updated. * stat1 = File.stat(filepath) # Take new snapshot. - * stat1.world_readable? # => nil # Snapshot shows not world-readable. + * stat1.world_readable?.to_s(8) # => "644" # Snapshot shows world-readable. * File.delete(filepath) # Clean up. + * stat1.world_readable?.to_s(8) # => "644" # Snapshot not updated. * ``` */ diff --git a/pathname_builtin.rb b/pathname_builtin.rb index 365547024b5..4cabfb30c4f 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -2530,9 +2530,8 @@ class Pathname # * FileTest * # call-seq: # world_readable? -> integer or nil # - # If the entry at the path in `self` exists and is readable by others, - # returns the integer [permissions](rdoc-ref:file/filesystem_modes.md@Permissions) - # for the entry; + # Returns the integer [permissions](rdoc-ref:file/filesystem_modes.md@Permissions) + # for the entry at the path in `self` if the entry exists and is readable by others; # otherwise, returns `nil`: # # ```ruby