From: Marc Heiler Date: 2012-02-05T18:57:12+09:00 Subject: Hooking a function to run in IRB context (but only in IRB context)? Hi. I start IRB. Then I do something like: > pj (Input is "pj") The result is: NameError: undefined local variable or method `pj' for # 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/.