On 2005-04-11, Martin DeMello <martindemello / yahoo.com> wrote: > Csaba Henk <csaba / phony_for_avoiding_spam.org> wrote: >> >> A line read by irb is evaluated in an IRB::Irb instance (that class is >> defined in irb.rb). As I can read fxirb.rb, you didn't overwrite #gets >> anywhere seeked by IRB::Irb upon method lookup. So what happens is that >> the good old Kernel#gets is called. > > I tried IRB::Irb#gets and IRB::Context#gets, but neither of them were > getting called. It did indeed turn out to be Kernel#gets - is it safe to > just override that? I'm sorry, I was wrong. A command read by irb is evaluated in the toplevel. In general, you can access the toplevel object as eval "self", TOPLEVEL_BINDING but with irb, the api-friendly way is as follows: IRB.context.workspace.main (that is, with an alternative config this might differ from the toplevel object, but this form always gives you the object which is used by irb for evaluation). So, just define #gets as a singleton method of the above object. Csaba