From 7342f83ab5c42b7aa8ac5e3bb258c1447f863357 Mon Sep 17 00:00:00 2001 From: icebaker Date: Tue, 16 May 2023 19:22:55 -0300 Subject: improving stream flow --- controllers/instance.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'controllers/instance.rb') 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 -- cgit v1.2.3