--f46d043be25e8dd08404b834b7cd Content-Type: text/plain; charset=ISO-8859-1 On Sun, Feb 5, 2012 at 3:57 AM, Marc Heiler <shevegen / linuxmail.org> wrote: > Hi. > > I start IRB. > > Then I do something like: > > > pj > > (Input is "pj") > > The result is: > > NameError: undefined local variable or method `pj' for > #<Object:0xb751d954> > from (irb):7 > > > Ok, this is what normally happens. > > Now I want to hook up a specific class. Let's call it > > class Foo > end > > This class should intercept BEFORE NameError happens. It should then > check that input, like: > > Foo.new(input) > Foo.new('pj') > > And it will decide against an internal list: > > - When the input was found in the internal list, an action is done, > and no error is reported. > > - When the input was NOT found, a NameError is triggered just as it > currently is. > > In other words, I need the ability to hook up a specific class before > NameError happens in IRB. > > Does anyone have an idea how to do that? > > -- > Posted via http://www.ruby-forum.com/. > > Don't know how to do it with irb, but if you use pry (which is way better than irb), you can write a command for it https://github.com/pry/pry/wiki/Command-system --f46d043be25e8dd08404b834b7cd--