Spice up your boring IRB (Irbtools)

IRB stands for interactive ruby, it is a tool for interactively executing ruby expressions read from a standard input. To invoke it, type irb at the shell or command prompt, and begin entering Ruby statements and expressions. But it has some limitations. A solution to this is called ‘irbtools‘, which make using irb easier and more fun. It improves Ruby’s irb console like colored output and lots of helpful methods.

Setup

Install the gem by using:

1

gem install irbtools

or

Add it to your project’s Gemfile:

1

gem'irbtools',require:'irbtools/binding'

Usage

IRB executes code in ~/.irbrc on start-up.To use irbtools, put the following code in ~/.irbrc file:

1

require'irbtools'

We can start IRB directly from the code by calling,

1

binding.irb

When installing irbtools, some gems will not be installed. For example, the bond gem for better auto-completion. These are packaged as irbtools-more (requires ruby version >= 2.4). To use irbtools-more, change the .irbrc to:

References

Author: anjana

Nothing makes Anjana happier than writing down her experience and being appreciated for it. An ardent lover of coffee, books and series like Gossip Girls, Vampire Diaries. She is always on a stroll writing code while listening to classic Sonu Nigam/Anirudh tracks. Presently working as a RoR Developer at Red Panthers, she is a regular at the Ruby Meetups in town as well.