class Shell
Attributes
result[RW]
Public Class Methods
new()
click to toggle source
# File lib/troshka/editor/shell.rb, line 6 def initialize @binding = TOPLEVEL_BINDING $stdout = StringIO.new end
Public Instance Methods
run(str)
click to toggle source
# File lib/troshka/editor/shell.rb, line 11 def run(str) result = eval(str, @binding, "(troshka)") ::Troshka::App.last_result = result eval("_ = Troshka::App.last_result", @binding) exception = nil $stdout.rewind output = $stdout.read $stdout.truncate(0) $stdout.rewind rescue Exception => e output = nil obj = nil exception = e ensure return {code: str, output: output, obj: result, exception: exception} end