irb
irb (Interactive Ruby) was developed by Keiju
Ishitsuka. It allows you to enter commands at the prompt and have the
interpreter respond as if you were executing a program.
irb is useful to experiment with or to explore
Ruby.
irb [ options ] [ programfile ] [ argument... ]
Here are the irb options:
-fSuppresses loading of
~/.irbrc.-mMath mode. Performs calculations using rational numbers.
-dDebugger mode. Sets
$DEBUGtotrue.-rlibUses
requireto load the librarylibbefore executing the program.-v--versionDisplays the version of
irb.--inspectInspect mode (default).
--noinspectNoninspect mode (default for math mode).
--readlineUses the
readlinelibrary.--noreadlineSuppresses use of the
readlinelibrary.--promptmode--prompt-modemodeSets the prompt mode. Predefined prompt modes are
default,simple,xmp, andinf-ruby.--inf-ruby-modeSets the prompt mode to
inf-rubyand suppresses use of thereadlinelibrary.--simple-promptSets the prompt mode to simple mode.
--nopromptSuppresses the prompt display.
--tracerDisplays a trace of method calls.
--back-trace-limitnSets the depth of backtrace information to be displayed (default is 16).
Here is a sample irb interaction:
irb irb(main):001:0> a = 25 25 irb(main):002:0> a = 2 2 irb(main):003:0> matz@ev[sample] irb irb(main):001:0> a = 3 3 irb(main):002:0> a.times do |i| irb(main):003:1* puts i irb(main):004:1> end 0 1 2 3 irb(main):005:0> class Foo<Object irb(main):006:1> def foo irb(main):007:2> puts "foo" irb(main):008:2> end irb(main):009:1> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access