As I am going through my journey by adopting the Ruby language, I spend a lot of time inside IRb. It's just fantastic! But, as I am not very aware of it's capabilities, and still a “nubby” with Ruby, I would like to know the following:
- How can I “flush” the session, without restarting IRb (or is this not possible).
- How can I configure IRb to load a bunch of source files "hello.rb" and "hello_objects.rb", i.e. at startup? I am heavily working in these and it would be nice to know a short hand to load these classes, without manually typing 'load' for each again.
You can manage sessions in irb. Start irb and try this:
There is also the command "fg (number)" which switches between sessions. See: http://tagaholic.me/2009/05/11/demystifying-irb-commands.html
You can put any ruby code into your ~/.irbrc file, which will get evaluated whenever you run irb. In this case your require statements.
These are not direct answers but can apply to your desire to understand irb more.
A number of "irb" methods are available to the console object.
Have some fun playing around with those.
Another is the "conf" object that gives feedback about your irb environment:
I'm not sure it's possible to 'flush' a session. However, you can load your classes like this:
I believe what you're looking for is modifying your ~/.irbrc file. It was mentioned earlier, but no examples given. Here is a short example of requiring some common utilities you may want in your irb session: