Sha256: fa9ad2a2131af81e8af5ee2525bfa273c6ccf37663d09b026468af202b24cf49

Contents?: true

Size: 464 Bytes

Versions: 9

Compression:

Stored size: 464 Bytes

Contents

require 'irb'

module IRB
  ##
  # Starts an IRB session *inside* the given object.
  #
  # This code was adapted from a snippet on Massimiliano Mirra's website:
  # http://www.therubymine.com/articles/2007/01/29/programmare-dallinterno
  #
  def self.start_session context
    IRB.setup nil

    env = IRB::WorkSpace.new(context)
    irb = IRB::Irb.new(env)
    IRB.conf[:MAIN_CONTEXT] = irb.context

    catch :IRB_EXIT do
      irb.eval_input
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rumai-4.1.3 lib/rumai/irb.rb
rumai-4.1.2 lib/rumai/irb.rb
rumai-4.1.1 lib/rumai/irb.rb
rumai-4.1.0 lib/rumai/irb.rb
rumai-4.0.0 lib/rumai/irb.rb
rumai-3.3.1 lib/rumai/irb.rb
rumai-3.3.0 lib/rumai/irb.rb
rumai-3.2.4 lib/rumai/irb.rb
rumai-3.2.3 lib/rumai/irb.rb