Skip to content

Commit

Permalink
- add irb example
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansissel committed Apr 13, 2011
1 parent 4a45611 commit d5c3bd8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions irb-example.rb
@@ -0,0 +1,27 @@
# Code from http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/
require 'irb'

module IRB # :nodoc:
def self.start_session(binding)
unless @__initialized
args = ARGV
ARGV.replace(ARGV.dup)
IRB.setup(nil)
ARGV.replace(args)
@__initialized = true
end

workspace = WorkSpace.new(binding)

irb = Irb.new(workspace)

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

catch(:IRB_EXIT) do
irb.eval_input
end
end
end

IRB.start_session(binding)

0 comments on commit d5c3bd8

Please sign in to comment.