Module: IRB

Defined in:
lib/monkey/irb.rb

Defined Under Namespace

Modules: ExtendCommandBundle

Class Method Summary collapse

Class Method Details

.start_with_context(context = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/monkey/irb.rb', line 2

def IRB.start_with_context(context = nil)
  IRB.setup nil

  if @CONF[:SCRIPT]
    irb = Irb.new(nil, @CONF[:SCRIPT])
  else
    irb = Irb.new WorkSpace.new(TOPLEVEL_BINDING, context)
  end

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

  trap("SIGINT") do
    irb.signal_handle
  end

  begin
    catch(:IRB_EXIT) do
      irb.eval_input
    end
  ensure
    irb_at_exit
  end
end