1 .\" DO NOT MODIFY THIS FILE! it was generated by rd2
2 .TH irb-beta 1 "May 2001"
5 irb stands for `interactive ruby'. irb is a tool to execute interactively
6 ruby expressions read from stdin.
10 \& % ruby \-r irb \-e0
13 Either of the aboves. In the former style, options can be specified
16 \& % ruby \-r irb \-e0 \-\- \-v
20 Use of irb is easy if you know ruby. Executing irb, prompts are
21 displayed as follows. Then, enter expression of ruby. A input is
22 executed when it is syntacticaly completed.
25 \& irb(main):001:0> 1+2
27 \& irb(main):002:0> class Foo
28 \& irb(main):003:1> def foo
29 \& irb(main):004:2> print 1
30 \& irb(main):005:2> end
31 \& irb(main):006:1> end
35 And, Readline extesion module can be used with irb. Using Readline
36 is the standard default action if Readline is installed.
37 .SH Command line option
40 \& irb.rb [options] file_name opts
42 \& \-f suppress read ~/.irbrc
43 \& \-m bc mode (fraction or matrix are available)
44 \& \-d set $DEBUG to true (same as `ruby \-d')
45 \& \-r load\-module same as `ruby \-r'
46 \& \-\-inspect uses `inspect' for output (the default except bc mode)
47 \& \-\-noinspect doesn't uses inspect for output
48 \& \-\-readline uses Readline extension module
49 \& \-\-noreadline doesn't use Readline extension module
50 \& \-\-prompt prompt\-mode
51 \& \-\-prompt\-mode prompt\-mode
54 \& switches prompt mode. Pre\-defined prompt modes are
55 \& `defalut', `simple', `xmp' and `inf\-ruby'
58 \& \-\-inf\-ruby\-mode uses prompt appreciate for inf\-ruby\-mode on emacs.
61 \& Suppresses \-\-readline.
64 \& \-\-simple\-prompt simple prompt mode
65 \& \-\-noprompt no prompt
66 \& \-\-tracer display trace for each execution of commands.
67 \& \-\-back\-trace\-limit n
70 \& displayes backtrace top n and tail n. The default
74 \& \-\-irb_debug n sets internal debug level to n (It shouldn't be used)
75 \& \-v, \-\-version prints the version of irb
79 irb reads `~/.irbrc' when it is invoked. If `~/.irbrb' doesn't exist
80 irb try to read in the order `.irbrc', `irb.rc', `_irbrc' then `$irbrc'.
81 The following is altanative to the command line option. To use them
82 type as follows in an irb session.
84 \& IRB.conf[:IRB_NAME]="irb"
85 \& IRB.conf[:MATH_MODE]=false
86 \& IRB.conf[:USE_TRACER]=false
87 \& IRB.conf[:USE_LOADER]=false
88 \& IRB.conf[:IGNORE_SIGINT]=true
89 \& IRB.conf[:IGNORE_EOF]=false
90 \& IRB.conf[:INSPECT_MODE]=nil
91 \& IRB.conf[:IRB_RC] = nil
92 \& IRB.conf[:BACK_TRACE_LIMIT]=16
93 \& IRB.conf[:USE_LOADER] = false
94 \& IRB.conf[:USE_READLINE] = nil
95 \& IRB.conf[:USE_TRACER] = false
96 \& IRB.conf[:IGNORE_SIGINT] = true
97 \& IRB.conf[:IGNORE_EOF] = false
98 \& IRB.conf[:PROMPT_MODE] = :DEFALUT
99 \& IRB.conf[:PROMPT] = {...}
100 \& IRB.conf[:DEBUG_LEVEL]=0
101 \& IRB.conf[:VERBOSE]=true
103 .SH Customizing prompt
105 To costomize the prompt you set a variable
109 For example, describe as follows in `.irbrc'.
111 \& IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
112 \& :PROMPT_I => nil, # normal prompt
113 \& :PROMPT_S => nil, # prompt for continuated strings
114 \& :PROMPT_C => nil, # prompt for continuated statement
115 \& :RETURN => " ==>%s\\n" # format to return value
118 Then, invoke irb with the above prompt mode by
120 \& % irb \-\-prompt my\-prompt
122 Or add the following in `.irbrc'.
124 \& IRB.conf[:PROMPT_MODE] = :MY_PROMPT
126 Constants PROMPT_I, PROMPT_S and PROMPT_C specifies the format.
127 In the prompt specification, some special strings are available.
129 \& %N command name which is running
130 \& %m to_s of main object (self)
131 \& %M inspect of main object (self)
132 \& %l type of string(", ', /, ]), `]' is inner %w[...]
133 \& %NNi indent level. NN is degits and means as same as printf("%NNd").
138 For instance, the default prompt mode is defined as follows:
139 IRB.conf[:PROMPT_MODE][:DEFAULT] = {
144 PROMPT_I => "%N(%m):%03n:%i> ",
150 PROMPT_S => "%N(%m):%03n:%i%l ",
156 PROMPT_C => "%N(%m):%03n:%i* ",
164 RETURN is used to printf.
165 .SH Configurating subirb
167 The command line option or IRB.conf specify the default behavior of
168 (sub)irb. On the other hand, each conf of in the next sction `6. Command'
169 is used to individually configurate (sub)irb.
170 If proc is set to IRB.conf[:IRB_RC], its subirb will be invoked after
171 execution of that proc under giving the context of irb as its
172 aregument. By this mechanism each subirb can be configurated.
175 For irb commands, both simple name and `irb_'\-prefixed name are prepared.
182 if you've done cb (see below), exit from the binding mode.
189 Displays current configuration. Modifing the configuration is
190 achieved by sending message to `conf'.
196 conf.back_trace_limit
197 Sets display lines of backtrace as top n and tail n.
198 The default value is 16.
205 Sets debug level of irb.
211 conf.ignore_eof = true/false
212 Whether ^D (control\-d) will be ignored or not.
213 If false is set, ^D means quit.
219 conf.ignore_sigint= true/false
220 Whether ^C (control\-c) will be ignored or not.
221 If false is set, ^D means quit. If true,
224 \& during input: cancel inputing then return to top level.
225 \& during execute: abondon current execution.
232 conf.inf_ruby_mode = true/false
233 Whether inf\-ruby\-mode or not. The default value is false.
239 conf.inspect_mode = true/false/nil
240 Specifies inspect mode.
241 true: display inspect
243 nil: inspect mode in non math mode,
246 \& non inspect mode in math mode.
261 Whether bc mode or not.
267 conf.use_loader = true/false
268 Whether irb's own file reader method is used when load/require or not.
269 This mode is globaly affected (irb wide).
276 prompt for a continuating statement (e.g, immediately after of `if')
290 prompt for a continuating string
297 Whether ~/.irbrc is read or not.
303 conf.use_prompt = true/false
310 conf.use_readline = true/false/nil
311 Whether readline is used or not.
314 nil: intends to use readline except for inf\-reuby\-mode (default)
321 Whether verbose messages are display or not.
327 cb, irb_change_binding [obj]
328 Enter new binding which has a distinct scope of local variables.
329 If obj is given, obj will be self.
336 Invoke subirb. If obj is given, obj will be self.
350 Switch into specified subirb. The following is candidates of n:
356 \& self(obj which is specified of irb obj)
364 Kill subirb. The means of n is as same as the case of irb_fg.
368 \& _ The latest value of evaluation (it is local)
374 \& irb(main):001:0> irb # invoke subirb
375 \& irb#1(main):001:0> jobs # list of subirbs
376 \& #0\->irb on main (#<Thread:0x400fb7e4> : stop)
377 \& #1\->irb#1 on main (#<Thread:0x40125d64> : running)
379 \& irb#1(main):002:0> fg 0 # switch job
381 \& irb(main):002:0> class Foo;end
383 \& irb(main):003:0> irb Foo # invoke subirb which has the
389 \& irb#2(Foo):001:0> def foo # define Foo#foo
390 \& irb#2(Foo):002:1> print 1
391 \& irb#2(Foo):003:1> end
393 \& irb#2(Foo):004:0> fg 0 # switch job
395 \& irb(main):004:0> jobs # list of job
396 \& #0\->irb on main (#<Thread:0x400fb7e4> : running)
397 \& #1\->irb#1 on main (#<Thread:0x40125d64> : stop)
398 \& #2\->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
400 \& irb(main):005:0> Foo.instance_methods # Foo#foo is defined asurely
402 \& irb(main):006:0> fg 2 # switch job
404 \& irb#2(Foo):005:0> def bar # define Foo#bar
405 \& irb#2(Foo):006:1> print "bar"
406 \& irb#2(Foo):007:1> end
408 \& irb#2(Foo):010:0> Foo.instance_methods
410 \& irb#2(Foo):011:0> fg 0
412 \& irb(main):007:0> f = Foo.new
414 \& irb(main):008:0> irb f # invoke subirb which has the
417 \& # context of f (instance of Foo)
420 \& irb#3(#<Foo:0x4010af3c>):001:0> jobs
421 \& #0\->irb on main (#<Thread:0x400fb7e4> : stop)
422 \& #1\->irb#1 on main (#<Thread:0x40125d64> : stop)
423 \& #2\->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
424 \& #3\->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
426 \& irb#3(#<Foo:0x4010af3c>):002:0> foo # evaluate f.foo
428 \& irb#3(#<Foo:0x4010af3c>):003:0> bar # evaluate f.bar
430 \& irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# kill job
432 \& irb(main):009:0> jobs
433 \& #0\->irb on main (#<Thread:0x400fb7e4> : running)
435 \& irb(main):010:0> exit # exit
440 Because irb evaluates the inputs immediately after the imput is
441 syntactically completed, irb gives slight different result than
442 directly use ruby. Known difference is pointed out here.
443 .SH Declaration of the local variable
445 The following causes an error in ruby:
450 \& \-:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError)
454 Though, the above will successfully done by irb.
463 Ruby evaluates a code after reading entire of code and determination
464 of the scope of local variables. On the other hand, irb do
465 immediately. More precisely, irb evaluate at first
469 then foo is defined on this timing. It is because of this
471 If you'd like to detect those differences, begin...end can be used:
477 \& NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0>
479 \& (irb_local_binding):1:in `eval'
483 Implementation of Here\-document is incomplete.
486 Irb can not always recognize a symbol as to be Symbol. Concretely, an
487 expression have completed, however Irb regard it as continuation line.