Module: IRB

Defined in:
lib/ruckus/extensions/irb.rb

Class Method Summary collapse

Class Method Details

.start_session(binding) ⇒ Object

Lifted from errtheblog.com/posts/9-drop-to-irb Starts an IRB session with a specific binding. To use type: IRB.start_session(binding)



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

def self.start_session(binding)
  # XXX not used
  IRB.setup(nil)

  workspace = WorkSpace.new(binding)

  if @CONF[:SCRIPT]
    irb = Irb.new(workspace, @CONF[:SCRIPT])
  else
    irb = Irb.new(workspace)
  end

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

  trap("SIGINT") do
    irb.signal_handle
  end

  catch(:IRB_EXIT) do
    irb.eval_input
  end
end