IRB

IRB is an acronym for "interactive Ruby". It's a tool that provided alongside Ruby interpreter, which allows for the interactive execution of Ruby expressions. These expressions are delivered to IRB using standard input.

Let's quickly see IRB in action:

  ~  irb
2.1-head :001 >

When we enter the irb command, it throws a shell at us. The format of the shell prompt is as follows:

$RUBY_VERSION :$LINE_NUMBER >

You can customize this prompt to your liking. However, for now, just remember that whatever expression you enter at the prompt is interpreted as a Ruby expression and is evaluated right away.

Consider the following as an example:

irb
2.1-head :001 > 2+3
 => 5

As you can see, we entered an arithmetic expression to compute the sum of two numbers, ...

Get Mastering Chef now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.