File: //usr/share/ri/3.0.0/system/Binding/irb-i.ri
U:RDoc::AnyMethod[iI"irb:ETI"Binding#irb;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"IOpens an IRB session where +binding.irb+ is called which allows for ;TI"Ointeractive debugging. You can call any methods or variables available in ;TI"8the current scope, and mutate state if you need to.;To:RDoc::Markup::BlankLine o;
; [I"HGiven a Ruby file called +potato.rb+ containing the following code:;T@o:RDoc::Markup::Verbatim; [I"class Potato
;TI" def initialize
;TI" @cooked = false
;TI" binding.irb
;TI"* puts "Cooked potato: #{@cooked}"
;TI" end
;TI" end
;TI"
;TI"Potato.new
;T:@format0o;
; [I"HRunning <code>ruby potato.rb</code> will open an IRB session where ;TI"=+binding.irb+ is called, and you will see the following:;T@o;; [I"$ ruby potato.rb
;TI"
;TI" From: potato.rb @ line 4 :
;TI"
;TI" 1: class Potato
;TI" 2: def initialize
;TI" 3: @cooked = false
;TI" => 4: binding.irb
;TI"1 5: puts "Cooked potato: #{@cooked}"
;TI" 6: end
;TI" 7: end
;TI" 8:
;TI" 9: Potato.new
;TI"
;TI".irb(#<Potato:0x00007feea1916670>):001:0>
;T;
0o;
; [I"NYou can type any valid Ruby code and it will be evaluated in the current ;TI"Rcontext. This allows you to debug without having to run your code repeatedly:;T@o;; [
I"6irb(#<Potato:0x00007feea1916670>):001:0> @cooked
;TI"=> false
;TI"9irb(#<Potato:0x00007feea1916670>):002:0> self.class
;TI"=> Potato
;TI";irb(#<Potato:0x00007feea1916670>):003:0> caller.first
;TI"A=> ".../2.5.1/lib/ruby/2.5.0/irb/workspace.rb:85:in `eval'"
;TI"=irb(#<Potato:0x00007feea1916670>):004:0> @cooked = true
;TI"
=> true
;T;
0o;
; [I"RYou can exit the IRB session with the +exit+ command. Note that exiting will ;TI"Qresume execution where +binding.irb+ had paused it, as you can see from the ;TI"7output printed to standard output in this example:;T@o;; [I"3irb(#<Potato:0x00007feea1916670>):005:0> exit
;TI"Cooked potato: true
;T;
0o;
; [I",See IRB@IRB+Usage for more information.;T:
@fileI"lib/irb.rb;T:0@omit_headings_from_table_of_contents_below000[ I"();T@NFI"Binding;TcRDoc::NormalClass00