Class: ConsoleIpc::Evaluator
- Inherits:
-
Object
- Object
- ConsoleIpc::Evaluator
- Defined in:
- lib/console_ipc/evaluator.rb
Constant Summary collapse
- ERROR_BACKTRACE_LINES =
10
Instance Method Summary collapse
- #call(code) ⇒ Object
-
#initialize(context) ⇒ Evaluator
constructor
A new instance of Evaluator.
Constructor Details
#initialize(context) ⇒ Evaluator
Returns a new instance of Evaluator.
9 10 11 |
# File 'lib/console_ipc/evaluator.rb', line 9 def initialize(context) @context = context end |
Instance Method Details
#call(code) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/console_ipc/evaluator.rb', line 13 def call(code) stdout = StringIO.new stderr = StringIO.new with_output(stdout, stderr) do result = @context.eval(code, '(console-ipc)') response(stdout: stdout, stderr: stderr, result: result) end rescue StandardError => e error_response(stdout: stdout, stderr: stderr, error: e) end |