Class: IRBRemote::Server
- Inherits:
-
Object
- Object
- IRBRemote::Server
- Defined in:
- lib/irb_remote/server.rb
Instance Method Summary collapse
- #connected(input, output) ⇒ Object
-
#initialize(b) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(b) ⇒ Server
Returns a new instance of Server.
8 9 10 |
# File 'lib/irb_remote/server.rb', line 8 def initialize(b) @binding = b end |
Instance Method Details
#connected(input, output) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/irb_remote/server.rb', line 18 def connected(input, output) # irb uses Kernel#puts for output original_stdout = $stdout.dup $stdout = output workspace = IRB::WorkSpace.new(@binding) output.print(workspace.code_around_binding) irb = IRB::Irb.new(workspace, InputMethod.new(input, output), OutputMethod.new(output)) irb.run(IRB.conf) rescue DRb::DRbConnError ensure $stdout = original_stdout DRb.stop_service end |
#start ⇒ Object
12 13 14 15 16 |
# File 'lib/irb_remote/server.rb', line 12 def start IRB.setup(@binding.eval('__FILE__')) DRb.start_service("druby://#{IRBRemote.config.host}:#{IRBRemote.config.port}", self, safe_level: 1) DRb.thread.join end |