Or maybe

# untested
class RiDriver
  alias_method :oldpa, :process_args

  def process_args *args
    args = ARGV if args.nil?
    oldpa *args
  end
end

Then you can just do "ri.process_args arg_array"

Bill Atkins

On Wed, 6 Oct 2004 06:56:24 +0900, Brian Candler <b.candler / pobox.com> wrote:
> On Wed, Oct 06, 2004 at 05:41:53AM +0900, Mark Hubbart wrote:
> > > Add the following to your .irbrc file:
> > >
> > >    def ri(*names)
> > >      system(%{ri #{names.map {|name| name.to_s}.join(" ")}})
> > >    end
> >
> > Is it just me, or does that look a bit kludgy? ri itself is a ruby
> > script, and a ruby lib. It seems to me that there should be a clean
> > way of including the ri documentation in every object's methods... ie:
> >
> > irb> require 'irb/ri'
> >   ==> true
> > irb> Kernel.docs
> > [... paged documentation output ...]
> >   ==> Kernel
> > irb> Kernel.docs(:puts)
> > [...]
> >
> > ... and so on. This should be able to be one programatically, rather
> > than spawning an ri process.
> 
> Well, look at the source of /usr/local/bin/ri and you get only three lines:
> 
>   require 'rdoc/ri/ri_driver'
>   ri = RiDriver.new
>   ri.process_args
> 
> It's a shame that that process_args doesn't take an (optional) array
> parameter; it forces you to use ARGV. But you can frig it:
> 
> $ cat .irbrc
> require 'rdoc/ri/ri_driver'
> def ri(*names)
>   oargv = Object.const_get(:ARGV)
>   Object.const_set(:ARGV, names)
>   RiDriver.new.process_args
>   Object.const_set(:ARGV, oargv)
> end
> 
> $ irb
> irb(main):001:0> ri 'Enumerable'
> 
> Regards,
> 
> Brian.
> 
>