The ramblings of Chad Humphries

This isn’t where I parked my car…

Late last night I decided to perform my international duty and post a code snippet I have in my irbrc to Tim Lucas’s blog. Given that it seemed useful to Tim and others I thought I’d repost it here.

1 script_console_running = (ENV.include?('RAILS_ENV') and IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
3 rails_running = (ENV.include?('RAILS_ENV') and !IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
5 irb_standalone_running = (!script_console_running and !rails_running)

The code you just saw should be place anywhere near the top of your irbrc. You can then use any of the three variables available to run context specific IRB code.

Do you know of any other good bits of code magic for your irbrc file?


Written by spicycode

February 6, 2007 at 6:03 pm

Posted in programming

Tagged with ,

%d bloggers like this: