Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IRb: how to start an interactive ruby session with pre-loaded classes

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.
like image 451
Shyam Avatar asked Apr 16 '10 11:04

Shyam


1 Answers

I'm not sure it's possible to 'flush' a session. However, you can load your classes like this:

irb -r 'hello.rb' -r 'hello_objects.rb'
like image 157
Evgeny Shadchnev Avatar answered Oct 13 '22 22:10

Evgeny Shadchnev