Using IRB in NetBeans
I've been playing around with the IRB (Interactive Ruby Shell) Console in NetBeans. Generally, IRB is started from the command prompt in the directory containing your scripts. However, in NetBeans, it's launched from the NetBeans installation directory. So here are some tips on using IRB in NetBeans.
- Create a Ruby Application named IRBTest.
- In main.rb, define the following Blog class which we'll use for testing:
- From the Window menu, select IRB - Interactive Ruby Shell:
- The console will open in the editor's Output pane:
- Check your version of Ruby:
- Try to create a new Blog:
- The main.rb script file needs to be loaded into IRB first.
- Enter Dir.pwd
- Change to your project's lib directory:
- Try loading main.rb again:
- And now we can work with it:
- Add a body attribute to the class as follows:
- The try to set the body attribute:
- The script just needs to be reloaded and then you can use the up arrow to rerun the blog.body command:
- Closing the IRB window does not terminate your session (which is a good thing). To terminate your IRB session, type quit or exit.