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

() -> bool
setgid? → true or false

Returns whether the setgid bit is set in the special bits for the entry at the path in self:

Example
pn = Pathname('doc/t.tmp')
pn.write('foo')
mode = pn.stat.mode.to_s(8) # => "100664"
pn.setgid?                  # => false
pn.chmod(0o2644)            # Set the bit.
mode = pn.stat.mode.to_s(8) # => "102644"
pn.setgid?                  # => true
pn.delete                   # Clean up.

On Windows, the bit is never set; the method always returns false.

See also #root? #setuid? #rmtree #size also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0