summaryrefslogtreecommitdiff
path: root/controllers/instance.rb
diff options
context:
space:
mode:
authoricebaker <icebaker@proton.me>2023-05-16 19:22:55 -0300
committericebaker <icebaker@proton.me>2023-05-16 19:22:55 -0300
commit7342f83ab5c42b7aa8ac5e3bb258c1447f863357 (patch)
treefcf7f20cf80107e963df122cf560e8d9fd5e9495 /controllers/instance.rb
parentaf8af02155c22d91c9fef95ce46b863c7ed4c40e (diff)
improving stream flow
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