1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/doc/irb/irb.rd.jp
knu f8ab487e4d Initial revision
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-04-30 17:38:21 +00:00

391 lines
13 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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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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:
%