irb [options]

       irb  stands  for  `interactive ruby'. irb is a tool to execute interac-
       tively ruby expressions read from stdin.  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

           $ irb1.8
           irb(main):001:0> 1+2
           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

       And,  Readline  extesion module can be used with irb. Using Readline is
       the standard default action if Readline is installed.

       -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'

              uses `inspect' for output (the default except bc mode)

              doesn't uses inspect for output

              uses Readline extension module

              doesn't use Readline extension module

       --prompt prompt-mode

       --prompt-mode prompt-mode
              switches prompt mode. Pre-defined prompt  modes  are  `default',
              `simple', `xmp' and `inf-ruby'

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

       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_RC] = nil
           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] = {...}

Customizing prompt
       To costomize the prompt you set a variable


       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

           $ irb1.8 --prompt my-prompt

       Or add the following in `.irbrc'.

           %%    %
       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.  Com-
       mand'  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 mecha-
       nism each subirb can be configurated.

       For irb commands, both simple name and `irb_'-prefixed  name  are  pre-

       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'.

              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.

              Whether  irb's  own file reader method is used when load/require
              or not.  This mode is globaly affected (irb wide).

              prompt for a continuating statement (e.g, immediately  after  of

              standard prompt

              prompt for a continuating string

              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)

              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
                  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
           $ irb1.8
           irb(main):001:0> irb                        # invoke subirb
           irb#1(main):001:0> jobs                     # list of subirbs
           #0->irb on main (#<Thread:0x400fb7e4> : stop)
           irb#2(Foo):004:0> fg 0                      # switch job
           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)
           irb(main):005:0> Foo.instance_methods       # Foo#foo is defined asurely
           irb(main):006:0> fg 2                       # switch job
           irb#2(Foo):005:0> def bar                   # define Foo#bar
           irb#2(Foo):006:1>  print "bar"
           irb#2(Foo):007:1> end
           irb#2(Foo):010:0>  Foo.instance_methods
           ["bar", "foo"]
           irb#2(Foo):011:0> fg 0
           irb(main):007:0> f =
           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)
           irb#3(#<Foo:0x4010af3c>):002:0> foo         # evaluate
           irb#3(#<Foo:0x4010af3c>):003:0> bar         # evaluate
           irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# kill job
           irb(main):009:0> jobs
           #0->irb on main (#<Thread:0x400fb7e4> : running)
           irb(main):010:0> exit                       # exit

       Because irb evaluates the inputs immediately after the imput is syntac-
       tically 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"
           -:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError)
           evel "foo = 0"

       then foo is defined on this timing. It is because of this incompatibil-
       ity.  If you'd like to detect those  differences,  begin...end  can  be

           >> begin
           ?>   eval "foo = 0"
           >>   foo
           >> end
           NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0>
           (irb_local_binding):1:in `eval'

       Implementation of Here-document is incomplete.

       Irb  can  not always recognize a symbol as to be Symbol. Concretely, an
       expression have completed, however Irb regard it as continuation line.

                                 December 2002                       IRB1.8(1)
Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2017 Hurricane Electric. All Rights Reserved.