Class: IRuby::PlainBackend
- Inherits:
-
Object
- Object
- IRuby::PlainBackend
- Includes:
- History
- Defined in:
- lib/iruby/backend.rb
Instance Attribute Summary collapse
-
#eval_path ⇒ Object
readonly
Returns the value of attribute eval_path.
Instance Method Summary collapse
- #complete(code) ⇒ Object
- #eval(code, store_history) ⇒ Object
- #eval_binding ⇒ Object
-
#initialize ⇒ PlainBackend
constructor
A new instance of PlainBackend.
Constructor Details
#initialize ⇒ PlainBackend
Returns a new instance of PlainBackend.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/iruby/backend.rb', line 38 def initialize require 'irb' require 'irb/completion' IRB.setup(nil) @main = TOPLEVEL_BINDING.eval("self").dup init_main_object(@main) @workspace = IRB::WorkSpace.new(@main) @irb = IRB::Irb.new(@workspace) @eval_path = @irb.context.irb_path IRB.conf[:MAIN_CONTEXT] = @irb.context end |
Instance Attribute Details
#eval_path ⇒ Object (readonly)
Returns the value of attribute eval_path.
35 36 37 |
# File 'lib/iruby/backend.rb', line 35 def eval_path @eval_path end |
Instance Method Details
#complete(code) ⇒ Object
59 60 61 |
# File 'lib/iruby/backend.rb', line 59 def complete(code) IRB::InputCompletor::CompletionProc.call(code) end |
#eval(code, store_history) ⇒ Object
54 55 56 57 |
# File 'lib/iruby/backend.rb', line 54 def eval(code, store_history) @irb.context.evaluate(code, 0) @irb.context.last_value end |
#eval_binding ⇒ Object
50 51 52 |
# File 'lib/iruby/backend.rb', line 50 def eval_binding @workspace.binding end |