Class: WebConsole::REPL::IRB
- Inherits:
-
Object
- Object
- WebConsole::REPL::IRB
- Defined in:
- lib/web_console/repl/irb.rb
Overview
IRB\ Adapter
Adapter for the IRB REPL, which is the default Ruby on Rails console.
Defined Under Namespace
Classes: FiberInputMethod
Instance Method Summary collapse
-
#initialize(binding = TOPLEVEL_BINDING) ⇒ IRB
constructor
A new instance of IRB.
- #prompt ⇒ Object
- #send_input(input) ⇒ Object
Constructor Details
#initialize(binding = TOPLEVEL_BINDING) ⇒ IRB
Returns a new instance of IRB.
27 28 29 30 31 32 33 |
# File 'lib/web_console/repl/irb.rb', line 27 def initialize(binding = TOPLEVEL_BINDING) initialize_irb_session! @input = FiberInputMethod.new @irb = ::IRB::Irb.new(::IRB::WorkSpace.new(binding), @input) @fiber = Fiber.new { @irb.eval_input }.tap(&:resume) finalize_irb_session! end |
Instance Method Details
#prompt ⇒ Object
35 36 37 |
# File 'lib/web_console/repl/irb.rb', line 35 def prompt @input.prompt end |
#send_input(input) ⇒ Object
39 40 41 |
# File 'lib/web_console/repl/irb.rb', line 39 def send_input(input) Stream.threadsafe_capture! { @fiber.resume("#{input}\n") } end |