Skip to content

Commit 3d43367

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Harmonize grpowned? methods
1 parent a4b049a commit 3d43367

2 files changed

Lines changed: 38 additions & 12 deletions

File tree

file.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,13 +2253,24 @@ rb_file_rowned_p(VALUE obj, VALUE fname)
22532253

22542254
/*
22552255
* call-seq:
2256-
* File.grpowned?(file_name) -> true or false
2256+
* File.grpowned?(object) -> true or false
22572257
*
2258-
* Returns <code>true</code> if the named file exists and the
2259-
* effective group id of the calling process is the owner of
2260-
* the file. Returns <code>false</code> on Windows.
2258+
* Returns whether the filesystem entry for the given +object+ exists,
2259+
* and the effective group id of the calling process is the owner of the entry.
22612260
*
2262-
* _file_name_ can be an IO object.
2261+
* The given +object+ may be the string path to a file or directory entry:
2262+
*
2263+
* File.grpowned?('lib') # => true
2264+
* File.grpowned?('README.md') # => true
2265+
* File.grpowned?('/etc/passwd') # => false
2266+
* File.grpowned?('nosuch') # => false
2267+
*
2268+
* Or an open IO stream:
2269+
*
2270+
* File.open('README.md', 'r') {|file| File.grpowned?(file) } # => true
2271+
* File.open('/etc/passwd', 'r') {|file| File.grpowned?(file) } # => false
2272+
*
2273+
* Returns +false+ on Windows.
22632274
*/
22642275

22652276
static VALUE
@@ -6374,15 +6385,19 @@ rb_stat_rowned(VALUE obj)
63746385
}
63756386

63766387
/*
6377-
* call-seq:
6378-
* stat.grpowned? -> true or false
6388+
* call-seq:
6389+
* stat.grpowned?(path) -> true or false
6390+
*
6391+
* Returns whether the filesystem entry for the given string +path+ exists,
6392+
* and the effective group id of the calling process is the owner of the entry:
63796393
*
6380-
* Returns true if the effective group id of the process is the same as
6381-
* the group id of <i>stat</i>. On Windows, returns <code>false</code>.
6394+
* File.stat('README.md').grpowned? # => true
6395+
* File.stat('lib').grpowned? # => true
6396+
* File.stat('/etc/passwd').grpowned? # => false
63826397
*
6383-
* File.stat("testfile").grpowned? #=> true
6384-
* File.stat("/etc/passwd").grpowned? #=> false
6398+
* Raises an exception if there is no entry at the given +path+.
63856399
*
6400+
* Returns +false+ on Windows.
63866401
*/
63876402

63886403
static VALUE

pathname_builtin.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,18 @@ def executable_real?() FileTest.executable_real?(@path) end
16741674
#
16751675
def exist?() FileTest.exist?(@path) end
16761676

1677-
# See <tt>FileTest.grpowned?</tt>.
1677+
# call-seq:
1678+
# grpowned?(path) -> true or false
1679+
#
1680+
# Returns whether the filesystem entry for the path stored in +self+ exists,
1681+
# and the effective group id of the calling process is the owner of the entry:
1682+
#
1683+
# Pathname('README.md').grpowned? # => true
1684+
# Pathname('lib').grpowned? # => true
1685+
# Pathname('/etc/passwd').grpowned? # => false
1686+
# Pathname('nosuch').grpowned? # => false
1687+
#
1688+
# Returns +false+ on Windows.
16781689
def grpowned?() FileTest.grpowned?(@path) end
16791690

16801691
# :markup: markdown

0 commit comments

Comments
 (0)