summaryrefslogtreecommitdiff
path: root/controllers/instance.rb
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/instance.rb')
-rw-r--r--controllers/instance.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/controllers/instance.rb b/controllers/instance.rb
index 80ac9be..e0729e6 100644
--- a/controllers/instance.rb
+++ b/controllers/instance.rb
@@ -5,6 +5,7 @@ require 'yaml'
require_relative '../logic/helpers/hash'
require_relative '../components/provider'
require_relative '../components/storage'
+require_relative '../components/stream'
require_relative './interfaces/repl'
require_relative './interfaces/eval'
require_relative './session'
@@ -30,16 +31,14 @@ module NanoBot
@session.state
end
- def eval(input)
+ def eval(input, &block)
+ @stream.callback = block if block && @stream.is_a?(Components::Stream)
+
Interfaces::Eval.evaluate(input, @cartridge, @session)
- return unless @stream.is_a?(StringIO)
+ return unless @stream.is_a?(Components::Stream)
- @stream.flush
- result = @stream.string.clone
- @stream.truncate(0)
- @stream.rewind
- result
+ @stream.finish
end
def repl