Yukihiro Matsumoto
10/20/2006 8:09:00 AM
Hi,
In message "Re: Etc.dir, Etc.name"
on Fri, 20 Oct 2006 16:40:13 +0900, Ronald Fischer <ronaldf@eml.cc> writes:
|I found some of the Etc functions missing which are mentioned in
|Matsumoto's book "Ruby in a nutshell", for example Etc.dir and
|Etc.shell. OTOH, Etc.name exists (for example):
|
|irb(main):002:0> Etc.dir
|NoMethodError: undefined method `dir' for Etc:Module
| from (irb):2
|irb(main):003:0> Etc.name
|=> "Etc"
|irb(main):004:0> Etc.shell
|NoMethodError: undefined method `shell' for Etc:Module
| from (irb):4
| from :0
I don't have the book at hand right now (since I am staying at the
hotel in Denver for RubyConf), but Etc module never had methods dir
and shell. If it says so, it is a bug in the book. Sorry.
Actually, the value returned from Etc#getpwnam has dir and shell
methods. Use them as in the following code:
pw = Etc.getpwnam('root')
p pw.dir # root's home directory
p pw.shell # root's shell
matz.