Eric Sunshine <sunshine / sunshineco.com> wrote in message news:<200402012329.AA01538 / sunshineco.com>...
> On Mon, 2 Feb 2004 07:54:50 +0900, Mark J. Reed wrote:
> > Okay, so enumerating users is easy enough.
> > require 'etc'
> > class Users
> >   include Etc
> >   include Enumerable
> >   def each
> >     setpwent
> >     while pw = getpwent
> >       yield pw
> >     end
> >     endpwent
> >   end
> > end
> > Users.new.each { |u| puts u.name }
> 
> Simpler:
> 
> require 'etc'
> class Users
>     include Etc
>     include Enumerable
>     alias :each :passwd
>     public :each
> end
> 
> Users.new.each { |u| puts u.name }

Apparently my earlier message got lost.  There is no need to wrap this
with the etc module.

require "etc"
Etc.passwd{ |s|
   p s.name
   p s.dir
}

This is documented in the Nutshell book and at
http://www.rubygarden.org/ruby?ProgrammingRubyTwo/Etc

Regards,

Dan