class method
Etc.group
() { (::Etc::Group group) -> void } -> void
() -> ::Etc::Group?
group { |struct| block }
group → Etc::Group
ext/etc/etc.c
View on GitHub ↗
static VALUE
etc_group(VALUE obj)
{
#ifdef HAVE_GETGRENT
struct group *grp;
if (rb_block_given_p()) {
each_group();
}
else if ((grp = getgrent()) != 0) {
return setup_group(grp);
}
#endif
return Qnil;
}
Provides a convenient Ruby iterator which executes a block for each entry in the /etc/group file.
The code block is passed an Group struct.
See ::getgrent above for details.
Example:
Example
require 'etc' Etc.group {|g| puts g.name + ": " + g.mem.join(', ') }