1IRB(1) Ruby Programmer's Reference Guide IRB(1)
2
4 irb — Interactive Ruby Shell
5
7 irb [--version] [-dfm] [-I directory] [-r library] [--[no]inspect]
8 [--[no]readline] [--prompt mode] [--prompt-mode mode]
9 [--inf-ruby-mode] [--simple-prompt] [--noprompt] [--tracer]
10 [--back-trace-limit n] [--irb_debug n] [--] [program_file]
11 [argument ...]
12
14 irb is the REPL(read-eval-print loop) environment for Ruby programs.
15
17 --version Prints the version of irb.
18
19 -E external[:internal]
20 --encoding external[:internal]
21 Same as `ruby -E' . Specifies the default value(s) for
22 external encodings and internal encoding. Values should be
23 separated with colon (:).
24
25 You can omit the one for internal encodings, then the
26 value (Encoding.default_internal) will be nil.
27
28 -I path Same as `ruby -I' . Specifies $LOAD_PATH directory
29
30 -U Same as `ruby -U' . Sets the default value for internal
31 encodings (Encoding.default_internal) to UTF-8.
32
33 -d Same as `ruby -d' . Sets $DEBUG to true.
34
35 -f Suppresses read of ~/.irbrc.
36
37 -h
38 --help Prints a summary of the options.
39
40 -r library Same as `ruby -r'. Causes irb to load the library using
41 require.
42
43 --inspect Uses `inspect' for output (default except for bc mode)
44
45 --noinspect Doesn't use inspect for output
46
47 --readline Uses Readline extension module.
48
49 --noreadline Doesn't use Readline extension module.
50
51 --prompt mode
52 --prompt-mode mode
53 Switch prompt mode. Pre-defined prompt modes are
54 `default', `simple', `xmp' and `inf-ruby'.
55
56 --inf-ruby-mode
57 Uses prompt appropriate for inf-ruby-mode on emacs. Sup‐
58 presses --readline.
59
60 --simple-prompt
61 Makes prompts simple.
62
63 --noprompt No prompt mode.
64
65 --tracer Displays trace for each execution of commands.
66
67 --back-trace-limit n
68 Displays backtrace top n and tail n. The default value is
69 16.
70
71 --irb_debug n Sets internal debug level to n (not for popular use)
72
74 IRBRC
75
76 Also irb depends on same variables as ruby(1).
77
79 ~/.irbrc Personal irb initialization.
80
82 % irb
83 irb(main):001:0> 1 + 1
84 2
85 irb(main):002:0> def t(x)
86 irb(main):003:1> x+1
87 irb(main):004:1> end
88 => :t
89 irb(main):005:0> t(3)
90 => 4
91 irb(main):006:0> if t(3) == 4
92 irb(main):007:1> p :ok
93 irb(main):008:1> end
94 :ok
95 => :ok
96 irb(main):009:0> quit
97 %
98
100 ruby(1).
101
103 · Security vulnerabilities should be reported via an email to
104 security@ruby-lang.org. Reported problems will be published after
105 being fixed.
106
107 · Other bugs and feature requests can be reported via the Ruby Issue
108 Tracking System (https://bugs.ruby-lang.org/). Do not report secu‐
109 rity vulnerabilities via this system because it publishes the vulner‐
110 abilities immediately.
111
113 Written by Keiju ISHITSUKA.
114
115UNIX November 15, 2012 UNIX