"Thomas R.Corbin" <tc / clark.net> writes:

> 1.  It seems like I've got to write an access method for class variables and
> cannot use attr_reader to get one automatically created for me.  Is that 
> correct?

Yes, but you can write your own version or attr_reader for class
variables if you want.

> 2.  I know the command line has the "-pi.bak" flag capability, but I'd like 
> to be able to control that kind of functionality w/in my program.  Python 
> has a real nice library, "fileinput.py" which works well for this situation.
> Does ruby have something like this already, or should I port the python 
> library?

Not knowing fileinput, I can't say.

You _can_ assign to the variable $-i, which has the same effect as the 
-i command line option:

     $-i = '.orig'

     while gets
       gsub /[aeiou]/, '*'
       print
     end

If this is in a file called t.rb, then the command

    % ruby t.rb t.rb

Changes t.rb to contain

     $-* = '.*r*g'

     wh*l* g*ts
       gs*b /[*****]/, '*'
       pr*nt
     *nd

and leaves the original in t.rb.orig.

There's also a module called ftools than does a lot of file copying and 
related stuff.


Regards


Dave