diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-04-30 17:38:21 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-04-30 17:38:21 +0000 |
commit | 0b36b7976239b6e03fb47def9e41d1c17e7b38ec (patch) | |
tree | f5b4f478538ea7c4cc541fda4fe5a30274e472ed /doc | |
parent | fd31cfaaea0825cc0634c0d2294499420302ca7e (diff) | |
download | ruby-0b36b7976239b6e03fb47def9e41d1c17e7b38ec.tar.gz ruby-0b36b7976239b6e03fb47def9e41d1c17e7b38ec.tar.xz ruby-0b36b7976239b6e03fb47def9e41d1c17e7b38ec.zip |
Initial revision
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'doc')
-rw-r--r-- | doc/irb/irb.rd | 377 | ||||
-rw-r--r-- | doc/irb/irb.rd.jp | 391 |
2 files changed, 768 insertions, 0 deletions
diff --git a/doc/irb/irb.rd b/doc/irb/irb.rd new file mode 100644 index 000000000..77b59639d --- /dev/null +++ b/doc/irb/irb.rd @@ -0,0 +1,377 @@ +irb -- interactive ruby + $Release Version: 0.5 $ + $Revision$ + $Date$ + by Keiju ISHITSUKA(keiju@ishitsuka.com) + translate from japanese by gotoken-san + +==begin += What is irb? + +irb stands for `interactive ruby'. irb is a tool to execute interactively +ruby expressions read from stdin. + += Invoking + + % ruby -r irb -e0 + % irb + +Either of the aboves. In the former style, options can be specified +as follows: + + % ruby -r irb -e0 -- -v + += Usage + +Use of irb is easy if you know ruby. Executing irb, prompts are +displayed as follows. Then, enter expression of ruby. A input is +executed when it is syntacticaly completed. + + dim% irb + irb(main):001:0> 1+2 + 3 + irb(main):002:0> class Foo + irb(main):003:1> def foo + irb(main):004:2> print 1 + irb(main):005:2> end + irb(main):006:1> end + nil + irb(main):007:0> + +And, Readline extesion module can be used with irb. Using Readline +is the standard default action if Readline is installed. + += Command line option + + irb.rb [options] file_name opts + options: + -f suppress read ~/.irbrc + -m bc mode (fraction or matrix are available) + -d set $DEBUG to true (same as `ruby -d') + -r load-module same as `ruby -r' + --inspect uses `inspect' for output (the default except bc mode) + --noinspect doesn't uses inspect for output + --readline uses Readline extension module + --noreadline doesn't use Readline extension module + --prompt prompt-mode + --prompt-mode prompt-mode + switches prompt mode. Pre-defined prompt modes are + `defalut', `simple', `xmp' and `inf-ruby' + + --inf-ruby-mode uses prompt appreciate for inf-ruby-mode on emacs. + Suppresses --readline. + --simple-prompt simple prompt mode + --noprompt no prompt + --tracer display trace for each execution of commands. + --back-trace-limit n + displayes backtrace top n and tail n. The default + value is 16. + --irb_debug n sets internal debug level to n (It shouldn't be used) + -v, --version prints the version of irb + + + += Configurations + +irb reads `~/.irbrc' when it is invoked. If `~/.irbrb' doesn't exist +irb try to read in the order `.irbrc', `irb.rc', `_irbrc' then `$irbrc'. + +The following is altanative to the command line option. To use them +type as follows in an irb session. + + IRB.conf[:IRB_NAME]="irb" + IRB.conf[:MATH_MODE]=false + IRB.conf[:USE_TRACER]=false + IRB.conf[:USE_LOADER]=false + IRB.conf[:IGNORE_SIGINT]=true + IRB.conf[:IGNORE_EOF]=false + IRB.conf[:INSPECT_MODE]=nil + IRB.conf[:IRB_RC] = nil + IRB.conf[:BACK_TRACE_LIMIT]=16 + IRB.conf[:USE_LOADER] = false + IRB.conf[:USE_READLINE] = nil + IRB.conf[:USE_TRACER] = false + IRB.conf[:IGNORE_SIGINT] = true + IRB.conf[:IGNORE_EOF] = false + IRB.conf[:PROMPT_MODE] = :DEFALUT + IRB.conf[:PROMPT] = {...} + IRB.conf[:DEBUG_LEVEL]=0 + IRB.conf[:VERBOSE]=true + +== Customizing prompt + +To costomize the prompt you set a variable + + IRB.conf[:PROMPT] + +For example, describe as follows in `.irbrc'. + + IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode + :PROMPT_I => nil, # normal prompt + :PROMPT_S => nil, # prompt for continuated strings + :PROMPT_C => nil, # prompt for continuated statement + :RETURN => " ==>%s\n" # format to return value + } + +Then, invoke irb with the above prompt mode by + + % irb --prompt my-prompt + +Or add the following in `.irbrc'. + + IRB.conf[:PROMPT_MODE] = :MY_PROMPT + +Constants PROMPT_I, PROMPT_S and PROMPT_C specifies the format. +In the prompt specification, some special strings are available. + + %N command name which is running + %m to_s of main object (self) + %M inspect of main object (self) + %l type of string(", ', /, ]), `]' is inner %w[...] + %NNi indent level. NN is degits and means as same as printf("%NNd"). + It can be ommited + %NNn line number. + %% % + +For instance, the default prompt mode is defined as follows: + +IRB.conf[:PROMPT_MODE][:DEFAULT] = { + :PROMPT_I => "%N(%m):%03n:%i> ", + :PROMPT_S => "%N(%m):%03n:%i%l ", + :PROMPT_C => "%N(%m):%03n:%i* ", + :RETURN => "%s\n" +} + +RETURN is used to printf. + +== Configurating subirb + +The command line option or IRB.conf specify the default behavior of +(sub)irb. On the other hand, each conf of in the next sction `6. Command' +is used to individually configurate (sub)irb. + +If proc is set to IRB.conf[:IRB_RC], its subirb will be invoked after +execution of that proc under giving the context of irb as its +aregument. By this mechanism each subirb can be configurated. + += Command + +For irb commands, both simple name and `irb_'-prefixed name are prepared. + +--- exit, quit, irb_exit + Quits (sub)irb. + if you've done cb (see below), exit from the binding mode. + +--- conf, irb_context + Displays current configuration. Modifing the configuration is + achieved by sending message to `conf'. + +--- conf.back_trace_limit + Sets display lines of backtrace as top n and tail n. + The default value is 16. + +--- conf.debug_level = N + Sets debug level of irb. + +--- conf.ignore_eof = true/false + Whether ^D (control-d) will be ignored or not. + If false is set, ^D means quit. + +--- conf.ignore_sigint= true/false + Whether ^C (control-c) will be ignored or not. + If false is set, ^D means quit. If true, + during input: cancel inputing then return to top level. + during execute: abondon current execution. + +--- conf.inf_ruby_mode = true/false + Whether inf-ruby-mode or not. The default value is false. + +--- conf.inspect_mode = true/false/nil + Specifies inspect mode. + true: display inspect + false: display to_s + nil: inspect mode in non math mode, + non inspect mode in math mode. + +--- conf.irb_level + The level of cb. + +--- conf.math_mode + Whether bc mode or not. + +--- conf.use_loader = true/false + Whether irb's own file reader method is used when load/require or not. + This mode is globaly affected (irb wide). + +--- conf.prompt_c + prompt for a continuating statement (e.g, immediately after of `if') + +--- conf.prompt_i + standard prompt + +--- conf.prompt_s + prompt for a continuating string + +--- conf.rc + Whether ~/.irbrc is read or not. + +--- conf.use_prompt = true/false + Prompting or not. + +--- conf.use_readline = true/false/nil + Whether readline is used or not. + true: uses + false: doen't use + nil: intends to use readline except for inf-reuby-mode (default) + +--- conf.verbose=T/F + Whether verbose messages are display or not. + +--- cb, irb_change_binding [obj] + Enter new binding which has a distinct scope of local variables. + If obj is given, obj will be self. + +--- irb [obj] + Invoke subirb. If obj is given, obj will be self. + +--- jobs, irb_jobs + List of subirb + +--- fg n, irb_fg n + Switch into specified subirb. The following is candidates of n: + + irb number + thhread + irb object + self(obj which is specified of irb obj) + +--- kill n, irb_kill n + Kill subirb. The means of n is as same as the case of irb_fg. + += System variable + + _ The latest value of evaluation (it is local) + + += Session Example + + dim% ruby irb.rb + irb(main):001:0> irb # invoke subirb + irb#1(main):001:0> jobs # list of subirbs + #0->irb on main (#<Thread:0x400fb7e4> : stop) + #1->irb#1 on main (#<Thread:0x40125d64> : running) + nil + irb#1(main):002:0> fg 0 # switch job + nil + irb(main):002:0> class Foo;end + nil + irb(main):003:0> irb Foo # invoke subirb which has the + # context of Foo + irb#2(Foo):001:0> def foo # define Foo#foo + irb#2(Foo):002:1> print 1 + irb#2(Foo):003:1> end + nil + irb#2(Foo):004:0> fg 0 # switch job + nil + irb(main):004:0> jobs # list of job + #0->irb on main (#<Thread:0x400fb7e4> : running) + #1->irb#1 on main (#<Thread:0x40125d64> : stop) + #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop) + nil + irb(main):005:0> Foo.instance_methods # Foo#foo is defined asurely + ["foo"] + irb(main):006:0> fg 2 # switch job + nil + irb#2(Foo):005:0> def bar # define Foo#bar + irb#2(Foo):006:1> print "bar" + irb#2(Foo):007:1> end + nil + irb#2(Foo):010:0> Foo.instance_methods + ["bar", "foo"] + irb#2(Foo):011:0> fg 0 + nil + irb(main):007:0> f = Foo.new + #<Foo:0x4010af3c> + irb(main):008:0> irb f # invoke subirb which has the + # context of f (instance of Foo) + irb#3(#<Foo:0x4010af3c>):001:0> jobs + #0->irb on main (#<Thread:0x400fb7e4> : stop) + #1->irb#1 on main (#<Thread:0x40125d64> : stop) + #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop) + #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running) + nil + irb#3(#<Foo:0x4010af3c>):002:0> foo # evaluate f.foo + 1nil + irb#3(#<Foo:0x4010af3c>):003:0> bar # evaluate f.bar + barnil + irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# kill job + nil + irb(main):009:0> jobs + #0->irb on main (#<Thread:0x400fb7e4> : running) + nil + irb(main):010:0> exit # exit + dim% + += Restrictions + +Because irb evaluates the inputs immediately after the imput is +syntactically completed, irb gives slight different result than +directly use ruby. Known difference is pointed out here. + + +== Declaration of the local variable + +The following causes an error in ruby: + + eval "foo = 0" + foo + -- + -:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError) + --- + NameError + +Though, the above will successfully done by irb. + + >> eval "foo = 0" + => 0 + >> foo + => 0 + +Ruby evaluates a code after reading entire of code and determination +of the scope of local variables. On the other hand, irb do +immediately. More precisely, irb evaluate at first + + evel "foo = 0" + +then foo is defined on this timing. It is because of this +incompatibility. + +If you'd like to detect those differences, begin...end can be used: + + >> begin + ?> eval "foo = 0" + >> foo + >> end + NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0> + (irb):3 + (irb_local_binding):1:in `eval' + +== Here-document + +Implementation of Here-document is incomplete. + +== Symbol + +Irb can not always recognize a symbol as to be Symbol. Concretely, an +expression have completed, however Irb regard it as continuation line. + +==end + +% Begin Emacs Environment +% Local Variables: +% mode: text +% comment-column: 0 +% comment-start: "%" +% comment-end: "\n" +% End: +% diff --git a/doc/irb/irb.rd.jp b/doc/irb/irb.rd.jp new file mode 100644 index 000000000..cf65d3e3c --- /dev/null +++ b/doc/irb/irb.rd.jp @@ -0,0 +1,391 @@ +irb -- interactive ruby + $Release Version: 0.6 $ + $Revision$ + $Date$ + by Keiju ISHITSUKA(keiju@ishitsuka.com) +==begin += irb$B$H$O(B? + +irb$B$O(Binteractive ruby$B$NN,$G$9(B. ruby$B$N<0$rI8=`F~NO$+$i4JC1$KF~NO(B/$B<B9T$9(B +$B$k$?$a$N%D!<%k$G$9(B. + += $B5/F0(B + + % ruby -r irb -e0 + % irb + +$B$N$$$:$l$+$G9T$J$$$^$9(B. $BA0<T$N>l9g(Birb$B$X$N%*%W%7%g%s;XDj$O(B, $B0J2<$N$h$&$K(B +$B$J$j$^$9(B. + + % ruby -r irb -e0 -- -v + += $B;H$$J}(B + +irb$B$N;H$$J}$O(B, Ruby$B$5$(CN$C$F$$$l$P$$$?$C$F4JC1$G$9(B. $B4pK\E*$K$O(B irb $B$H(B +$B$$$&%3%^%s%I$r<B9T$9$k$@$1$G$9(B. irb$B$r<B9T$9$k$H(B, $B0J2<$N$h$&$J%W%m%s%W(B +$B%H$,I=$l$F$-$^$9(B. $B8e$O(B, ruby$B$N<0$rF~$l$F2<$5$$(B. $B<0$,407k$7$?;~E@$G<B9T(B +$B$5$l$^$9(B. + + dim% irb + irb(main):001:0> 1+2 + 3 + irb(main):002:0> class Foo + irb(main):003:1> def foo + irb(main):004:2> print 1 + irb(main):005:2> end + irb(main):006:1> end + nil + irb(main):007:0> + +$B$^$?(B, irb$B$O(BReadline$B%b%8%e!<%k$K$bBP1~$7$F$$$^$9(B. Readline$B%b%8%e!<%k$,(B +$B%$%s%9%H!<%k$5$l$F$$$k;~$K$O(B, $B$=$l$r;H$&$N$,I8=`$NF0:n$K$J$j$^$9(B. + += $B%3%^%s%I%*%W%7%g%s(B + + irb.rb [options] file_name opts + options: + -f ~/.irbrc $B$rFI$_9~$^$J$$(B. + -m bc$B%b!<%I(B($BJ,?t(B, $B9TNs$N7W;;$,$G$-$k(B) + -d $DEBUG $B$r(Btrue$B$K$9$k(B(ruby -d $B$HF1$8(B) + -r load-module ruby -r $B$HF1$8(B. + --inspect $B7k2L=PNO$K(Binspect$B$rMQ$$$k(B(bc$B%b!<%I0J30$O%G%U%)%k%H(B). + --noinspect $B7k2L=PNO$K(Binspect$B$rMQ$$$J$$(B. + --readline readline$B%i%$%V%i%j$rMxMQ$9$k(B. + --noreadline readline$B%i%$%V%i%j$rMxMQ$7$J$$(B. $B%G%U%)%k%H$NF0:n$O(B, + inf-reuby-mode$B0J30$G(Breadline$B%i%$%V%i%j$rMxMQ$7$h$&(B + $B$H$9$k(B. + --prompt prompt-mode + --prompt-mode prompt-mode + $B%W%m%s%W%H%b!<%I$r@ZBX$($^$9(B. $B8=:_Dj5A$5$l$F$$$k%W(B + $B%m%s%W%H%b!<%I$O(B, defalut, simple, xmp, inf-ruby$B$,(B + $BMQ0U$5$l$F$$$^$9(B. $B%G%U%)%k%H$O(Bdefault$B%W%m%s%W%H%b!<(B + $B%I$K$J$C$F$$$^$9(B. + + --inf-ruby-mode emacs$B$N(Binf-ruby-mode$BMQ$N%W%m%s%W%HI=<($r9T$J$&(B. $BFC(B + $B$K;XDj$,$J$$8B$j(B, readline$B%i%$%V%i%j$O;H$o$J$/$J$k(B. + --simple-prompt + $BHs>o$K%7%s%W%k$J%W%m%s%W%H$rMQ$$$k%b!<%I$G$9(B. + --noprompt $B%W%m%s%W%HI=<($r9T$J$o$J$$(B. + --tracer $B%3%^%s%I<B9T;~$K%H%l!<%9$r9T$J$&(B. + --back-trace-limit n + $B%P%C%/%H%l!<%9I=<($r%P%C%/%H%l!<%9$NF,$+$i(B n, $B8e$m(B + $B$+$i(Bn$B$@$19T$J$&(B. $B%G%U%)%k%H$O(B16 + --irb_debug n irb$B$N%G%P%C%0%G%P%C%0%l%Y%k$r(Bn$B$K@_Dj$9$k(B($BMxMQ$7$J(B + $B$$J}$,L5Fq$G$7$g$&(B). + -v, --version irb$B$N%P!<%8%g%s$rI=<($9$k(B + += $B%3%s%U%#%.%e%l!<%7%g%s(B + +irb$B5/F0;~$K(B``~/.irbrc''$B$rFI$_9~$_$^$9(B. $B$b$7B8:_$7$J$$>l9g$O(B, +``.irbrc'', ``irb.rc'', ``_irbrc'', ``$irbrc''$B$N=g$K(Bload$B$r;n$_$^$9(B. + +$B%*%W%7%g%s$r@_Dj$9$kBe$o$j$K(B, $B0J2<$N%3%^%s%I$G$b%G%U%)%k%H$NF0:n$r@_Dj(B +$B$G$-$^$9(B. + + IRB.conf[:IRB_NAME]="irb" + IRB.conf[:MATH_MODE]=false + IRB.conf[:USE_TRACER]=false + IRB.conf[:USE_LOADER]=false + IRB.conf[:IGNORE_SIGINT]=true + IRB.conf[:IGNORE_EOF]=false + IRB.conf[:INSPECT_MODE]=nil + IRB.conf[:IRB_RC] = nil + IRB.conf[:BACK_TRACE_LIMIT]=16 + IRB.conf[:USE_LOADER] = false + IRB.conf[:USE_READLINE] = nil + IRB.conf[:USE_TRACER] = false + IRB.conf[:IGNORE_SIGINT] = true + IRB.conf[:IGNORE_EOF] = false + IRB.conf[:PROMPT_MODE] = :DEFALUT + IRB.conf[:PROMPT] = {...} + IRB.conf[:DEBUG_LEVEL]=0 + IRB.conf[:VERBOSE]=true + +== $B%W%m%s%W%H$N@_Dj(B + +$B%W%m%s%W%H$r%+%9%?%^%$%:$7$?$$;~$K$O(B, + + IRB.conf[:PROMPT] + +$B$rMQ$$$^$9(B. $BNc$($P(B, .irbrc$B$NCf$G2<$N$h$&$J<0$r5-=R$7$^$9(B: + + IRB.conf[:PROMPT][:MY_PROMPT] = { # $B%W%m%s%W%H%b!<%I$NL>A0(B + :PROMPT_I => nil, # $BDL>o$N%W%m%s%W%H(B + :PROMPT_S => nil, # $BJ8;zNs$J$I$N7QB39T$N%W%m%s%W%H(B + :PROMPT_C => nil, # $B<0$,7QB3$7$F$$$k;~$N%W%m%s%W%H(B + :RETURN => " ==>%s\n" # $B%j%?!<%s;~$N%W%m%s%W%H(B + } + +$B%W%m%s%W%H%b!<%I$r;XDj$7$?$$;~$K$O(B, + + irb --prompt my-prompt + +$B$G$=$N%W%m%s%W%H%b!<%I$G5/F0$5$l$^$9(B. $B$^$?$O(B, .irbrc$B$K2<<0$r5-=R$7$F$b(B +OK$B$G$9(B. + + IRB.conf[:PROMPT_MODE] = :MY_PROMPT + +PROMPT_I, PROMPT_S, PROMPT_C$B$O(B, $B%U%)!<%^%C%H$r;XDj$7$^$9(B. + + %N $B5/F0$7$F$$$k%3%^%s%IL>$,=PNO$5$l$k(B. + %m main$B%*%V%8%'%/%H(B(self)$B$,(Bto_s$B$G=PNO$5$l$k(B. + %M main$B%*%V%8%'%/%H(B(self)$B$,(Binspect$B$5$l$F=PNO$5$l$k(B. + %l $BJ8;zNsCf$N%?%$%W$rI=$9(B(", ', /, ], `]'$B$O(B%w$B$NCf$N;~(B) + %NNi $B%$%s%G%s%H$N%l%Y%k$rI=$9(B. NN$B$O?t;z$,F~$j(Bprintf$B$N(B%NNd$B$HF1$8(B. $B>J(B + $BN,2DG=(B + %NNn $B9THV9f$rI=$7$^$9(B. + %% % + +$BNc$($P(B, $B%G%U%)%k%H$N%W%m%s%W%H%b!<%I$O(B: + + IRB.conf[:PROMPT_MODE][:DEFAULT] = { + :PROMPT_I => "%N(%m):%03n:%i> ", + :PROMPT_S => "%N(%m):%03n:%i%l ", + :PROMPT_C => "%N(%m):%03n:%i* ", + :RETURN => "%s\n" + } + +$B$H$J$C$F$$$^$9(B. + +RETURN$B$O(B, $B8=:_$N$H$3$m(Bprintf$B7A<0$G$9(B. $B>-Mh;EMM$,JQ$o$k$+$bCN$l$^$;$s(B. + +== $B%5%V(Birb$B$N@_Dj(B + +$B%3%^%s%I%i%$%s%*%W%7%g%s$*$h$S(BIRB.conf$B$O(B($B%5%V(B)irb$B5/F0;~$N%G%U%)%k%H$N(B +$B@_Dj$r7h$a$k$b$N$G(B, `5. $B%3%^%s%I(B'$B$K$"$k(Bconf$B$G8DJL$N(B($B%5%V(B)irb$B$N@_Dj$,$G(B +$B$-$k$h$&$K$J$C$F$$$^$9(B. + +IRB.conf[:IRB_RC]$B$K(Bproc$B$,@_Dj$5$l$F$$$k$H(B, $B%5%V(Birb$B$r5/F0$9$k;~$K$=$N(B +proc$B$r(Birb$B$N%3%s%F%-%9%H$r0z?t$H$7$F8F$S=P$7$^$9(B. $B$3$l$K$h$C$F8DJL$N%5(B +$B%V(Birb$B$4$H$K@_Dj$rJQ$($k$3$H$,$G$-$k$h$&$K$J$j$^$9(B. + + += $B%3%^%s%I(B + +irb$B3HD%%3%^%s%I$O(B, $B4JC1$JL>A0$HF,$K(B`irb_'$B$r$D$1$?L>A0$HN>J}Dj5A$5$l$F(B +$B$$$^$9(B. $B$3$l$O(B, $B4JC1$JL>A0$,(Boverride$B$5$l$?;~$N$?$a$G$9(B. + +--- exit, quit, irb_exit + $B=*N;$9$k(B. + $B%5%V(Birb$B$N>l9g(B, $B$=$N%5%V(Birb$B$r=*N;$9$k(B. + cb$B$7$F$$$k>l9g(B, $B$=$N%P%$%s%G%#%s%0$N%b!<%I$r=*N;$9$k(B. + +--- conf, irb_context + irb$B$N8=:_$N@_Dj$rI=<($9$k(B. $B@_Dj$NJQ99$O(B, conf$B$K%a%C%;!<%8$rAw$k$3(B + $B$H$K$h$C$F9T$J$($k(B. + +--- conf.back_trace_limit + $B%P%C%/%H%l!<%9I=<($r%P%C%/%H%l!<%9$NF,$+$i(Bn, $B8e$m$+$i(Bn$B$@$19T$J$&(B. + $B%G%U%)%k%H$O(B16 + +--- conf.debug_level = N + irb$BMQ$N%G%P%C%0%l%Y%k$N@_Dj(B + +--- conf.ignore_eof = true/false + ^D$B$,F~NO$5$l$?;~$NF0:n$r@_Dj$9$k(B. true$B$N;~$O(B^D$B$rL5;k$9$k(B, false$B$N(B + $B;~$O(Birb$B$r=*N;$9$k(B. + +--- conf.ignore_sigint= true/false + ^C$B$,F~NO$5$l$?;~$NF0:n$r@_Dj$9$k(B. false$B;~$O(B, irb$B$r=*N;$9$k(B. true$B$N(B + $B;~$NF0:n$O0J2<$N$h$&$K$J$k(B: + $BF~NOCf(B: $B$3$l$^$GF~NO$7$?$b$N$r%-%c%s%;%k$7%H%C%W%l%Y%k$KLa$k(B. + $B<B9TCf(B: $B<B9T$rCf;_$9$k(B. + +--- conf.inf_ruby_mode = true/false + inf-ruby-mode$BMQ$N%W%m%s%W%HI=<($r9T$J$&(B. $B%G%U%)%k%H$O(Bfalse. + +--- conf.inspect_mode = true/false/nil + $B%$%s%9%Z%/%H%b!<%I$r@_Dj$9$k(B. + true: $B%$%s%9%Z%/%H$7$FI=<($9$k(B. + false: $BDL>o$N(Bprint$B$GI=<($9$k(B. + nil: $BDL>o%b!<%I$G$"$l$P(B, inspect mode$B$H$J$j(B, math$B%b!<%I$N;~$O(B, non + inspect mode$B$H$J$k(B. + +--- conf.irb_level + $B;2>H$N$_(B. irb$B$,2?CJ(Bcb$B$7$F$$$k$+(B? + +--- conf.math_mode + $B;2>H$N$_(B. bc$B%b!<%I(B($BJ,?t(B, $B9TNs$N7W;;$,$G$-$^$9(B)$B$+$I$&$+(B? + +--- conf.use_loader = true/false + load/require$B;~$K(Birb$B$N(Bfile$BFI$_9~$_5!G=$rMQ$$$k%b!<%I$N%9%$%C%A(B($B%G%U%)(B + $B%k%H$OMQ$$$J$$(B). $B$3$N%b!<%I$O(BIRB$BA4BN$KH?1G$5$l$k(B. + +--- conf.prompt_c + if$B$ND>8e$J$I(B, $B9T$,7QB3$7$F$$$k;~$N%W%m%s%W%H(B. + +--- conf.prompt_i + $BDL>o$N%W%m%s%W%H(B. + +--- conf.prompt_s + $BJ8;zNsCf$J$I$rI=$9%W%m%s%W%H(B. + +--- conf.rc + ~/.irbrc$B$rFI$_9~$s$@$+$I$&$+(B? + +--- conf.use_prompt = true/false + $B%W%m%s%W%HI=<($9$k$+$I$&$+(B? $B%G%U%)%k%H$G$O%W%m%s%W%H$rI=<($9$k(B. + +--- conf.use_readline = true/false/nil + readline$B$r;H$&$+$I$&$+(B? + true: readline$B$r;H$&(B. + false: readline$B$r;H$o$J$$(B. + nil: ($B%G%U%)%k%H(B)inf-reuby-mode$B0J30$G(Breadline$B%i%$%V%i%j$rMxMQ$7$h(B + $B$&$H$9$k(B. + +--- conf.verbose=T/F + irb$B$+$i$$$m$$$m$J%a%C%;!<%8$r=PNO$9$k$+(B? + +--- cb, irb_change_binding [obj] + $B%m!<%+%kJQ?t$N%9%3!<%W$,0c$&?7$?$J(Bbinding$B$K0\$k(B. obj$B$,;XDj$5$l$?(B + $B;~$O(B, $B$=$N(Bobj$B$r(Bself$B$H$9$k(B. + +--- irb [obj] + $B%5%V(Birb$B$rN)$A$"$2$k(B. obj$B$,;XDj$5$l$?;~$O(B, $B$=$N(Bobj$B$r(Bself$B$H$9$k(B. + +--- jobs, irb_jobs + $B%5%V(Birb$B$N%j%9%H(B + +--- fg n, irb_fg n + $B;XDj$7$?%5%V(Birb$B$K%9%$%C%A$9$k(B. n$B$O(B, $B<!$N$b$N$r;XDj$9$k(B. + + irb$BHV9f(B + $B%9%l%C%I(B + irb$B%*%V%8%'%/%H(B + self(irb obj$B$G5/F0$7$?;~$N(Bobj) + +--- kill n, irb_kill n + $B%5%V(Birb$B$r(Bkill$B$9$k(B. n$B$O(Bfg$B$HF1$8(B. + + += $B%7%9%F%`JQ?t(B + + _ $BA0$N7W;;$N<B9T7k2L$r3P$($F$$$k(B($B%m!<%+%kJQ?t(B). + += $B;HMQNc(B + +$B0J2<$N$h$&$J46$8$G$9(B. + + dim% ruby irb.rb + irb(main):001:0> irb # $B%5%V(Birb$B$NN)$A$"$2(B + irb#1(main):001:0> jobs # $B%5%V(Birb$B$N%j%9%H(B + #0->irb on main (#<Thread:0x400fb7e4> : stop) + #1->irb#1 on main (#<Thread:0x40125d64> : running) + nil + irb#1(main):002:0> fg 0 # job$B$N%9%$%C%A(B + nil + irb(main):002:0> class Foo;end + nil + irb(main):003:0> irb Foo # Foo$B$r%3%s%F%-%9%H$7$F(Birb + # $BN)$A$"$2(B + irb#2(Foo):001:0> def foo # Foo#foo$B$NDj5A(B + irb#2(Foo):002:1> print 1 + irb#2(Foo):003:1> end + nil + irb#2(Foo):004:0> fg 0 # job$B$r%9%$%C%A(B + nil + irb(main):004:0> jobs # job$B$N%j%9%H(B + #0->irb on main (#<Thread:0x400fb7e4> : running) + #1->irb#1 on main (#<Thread:0x40125d64> : stop) + #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop) + nil + irb(main):005:0> Foo.instance_methods # Foo#foo$B$,$A$c$s$HDj5A$5(B + # $B$l$F$$$k(B + ["foo"] + irb(main):006:0> fg 2 # job$B$r%9%$%C%A(B + nil + irb#2(Foo):005:0> def bar # Foo#bar$B$rDj5A(B + irb#2(Foo):006:1> print "bar" + irb#2(Foo):007:1> end + nil + irb#2(Foo):010:0> Foo.instance_methods + ["bar", "foo"] + irb#2(Foo):011:0> fg 0 + nil + irb(main):007:0> f = Foo.new + #<Foo:0x4010af3c> + irb(main):008:0> irb f # Foo$B$N%$%s%9%?%s%9$G(Birb$B$r(B + # $BN)$A$"$2$k(B. + irb#3(#<Foo:0x4010af3c>):001:0> jobs + #0->irb on main (#<Thread:0x400fb7e4> : stop) + #1->irb#1 on main (#<Thread:0x40125d64> : stop) + #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop) + #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running) + nil + irb#3(#<Foo:0x4010af3c>):002:0> foo # f.foo$B$N<B9T(B + nil + irb#3(#<Foo:0x4010af3c>):003:0> bar # f.bar$B$N<B9T(B + barnil + irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# job$B$N(Bkill + nil + irb(main):009:0> jobs + #0->irb on main (#<Thread:0x400fb7e4> : running) + nil + irb(main):010:0> exit # $B=*N;(B + dim% + += $B;HMQ>e$N@)8B(B + +irb$B$O(B, $BI>2A$G$-$k;~E@(B($B<0$,JD$8$?;~E@(B)$B$G$NC`<!<B9T$r9T$J$$$^$9(B. $B$7$?$,$C(B +$B$F(B, ruby$B$rD>@\;H$C$?;~$H(B, $B<c430[$J$kF0:n$r9T$J$&>l9g$,$"$j$^$9(B. + +$B8=:_L@$i$+$K$J$C$F$$$kLdBjE@$r@bL@$7$^$9(B. + +== $B%m!<%+%kJQ?t$N@k8@(B + +ruby$B$G$O(B, $B0J2<$N%W%m%0%i%`$O%(%i!<$K$J$j$^$9(B. + + eval "foo = 0" + foo + -- + -:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError) + --- + NameError + +$B$H$3$m$,(B, irb$B$rMQ$$$k$H(B + + >> eval "foo = 0" + => 0 + >> foo + => 0 + +$B$H$J$j(B, $B%(%i!<$r5/$3$7$^$;$s(B. $B$3$l$O(B, ruby$B$,:G=i$K%9%/%j%W%HA4BN$r%3%s(B +$B%Q%$%k$7$F%m!<%+%kJQ?t$r7hDj$9$k$+$i$G$9(B. $B$=$l$KBP$7(B, irb$B$O<B9T2DG=$K(B +$B$J$k(B($B<0$,JD$8$k(B)$B$H<+F0E*$KI>2A$7$F$$$k$+$i$G$9(B. $B>e5-$NNc$G$O(B, + + evel "foo = 0" + +$B$r9T$J$C$?;~E@$GI>2A$r9T$J$$(B, $B$=$N;~E@$GJQ?t$,Dj5A$5$l$k$?$a(B, $B<!<0$G(B +$BJQ?t(Bfoo$B$ODj5A$5$l$F$$$k$+$i$G$9(B. + +$B$3$N$h$&$J(Bruby$B$H(Birb$B$NF0:n$N0c$$$r2r7h$7$?$$>l9g$O(B, begin...end$B$G3g$C$F(B +$B%P%C%AE*$K<B9T$7$F2<$5$$(B: + + >> begin + ?> eval "foo = 0" + >> foo + >> end + NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0> + (irb):3 + (irb_local_binding):1:in `eval' + +== $B%R%"%I%-%e%a%s%H(B + +$B8=:_$N$H$3$m%R%"%I%-%e%a%s%H$N<BAu$OIT40A4$G$9(B. + +== $B%7%s%\%k(B + +$B%7%s%\%k$G$"$k$+$I$&$+$NH=CG$r4V0c$($k$3$H$,$"$j$^$9(B. $B6qBNE*$K$O<0$,40N;(B +$B$7$F$$$k$N$K7QB39T$H8+$J$9$3$H$,$"$j$^$9(B. + +==end + +% Begin Emacs Environment +% Local Variables: +% mode: text +% comment-column: 0 +% comment-start: "%" +% comment-end: "\n" +% End: +% + |