Module: IRB

Defined in:
debrew/irb.rb

Class Method Summary collapse

Class Method Details

.start_within(binding) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'debrew/irb.rb', line 7

def self.start_within(binding)
  unless @setup_done
    setup(nil, argv: [])
    @setup_done = true
  end

  workspace = WorkSpace.new(binding)
  irb = Irb.new(workspace)

  @CONF[:IRB_RC]&.call(irb.context)
  @CONF[:MAIN_CONTEXT] = irb.context

  prev_trap = trap("SIGINT") do
    irb.signal_handle
  end

  begin
    catch(:IRB_EXIT) do
      irb.eval_input
    end
  ensure
    trap("SIGINT", prev_trap)
    irb_at_exit
  end
end