Class: Etc::Group
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Enumerable,
::Struct
|
|
|
Instance Chain:
self,
::Struct
|
|
| Inherits: |
Struct
|
| Defined in: | ext/etc/etc.c |
Overview
Group is a placeholder ::Struct for user group database on Unix systems.
The struct contains the following members
- name
-
contains the name of the group as a String.
- passwd
-
contains the encrypted password as a String. An
'x'is returned if password access to the group is not available; an empty string is returned if no password is needed to obtain membership of the group. This is system-dependent. - gid
-
contains the group’s numeric ID as an integer.
- mem
-
is an Array of Strings containing the short login names of the members of the group.
Class Method Summary
-
.each {|group| ... } ⇒ Object
Iterates for each entry in the
/etc/groupfile if a block is given.
Class Method Details
.each {|group| ... } ⇒ Object
.each ⇒ Enumerator
Object
.each ⇒ Enumerator
Iterates for each entry in the /etc/group file if a block is given.
If no block is given, returns the Enumerator.
The code block is passed a Group struct.
Example:
require 'etc'
Etc::Group.each {|g|
puts g.name + ": " + g.mem.join(', ')
}
Etc::Group.collect {|g| g.name}
Etc::Group.select {|g| !g.mem.empty?}
# File 'ext/etc/etc.c', line 600
static VALUE
etc_each_group(VALUE obj)
{
RETURN_ENUMERATOR(obj, 0, 0);
each_group();
return obj;
}