mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 08:25:20 +08:00
[DOC] Harmonize world_readable? methods
This commit is contained in:
1 parent
f33766720c
commit
8c82ca2c3f
2 files changed
+14
-14
Notes:
git
2026-10-15 23:48:53 +00:00
Merged: https://github.com/ruby/ruby/pull/19380 Merged-By: peterzhu2118 <peter@peterzhu.ca>
No files matched your search
@@ -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.
|
||||
* ```
|
||||
*/
|
||||
|
||||
|
||||
+2
-3
@@ -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
|
||||
|
||||
Reference in new issue
Block a user