Sha256: 3f22fd69504bb8b5878b0ec4e2eda6092602884d1445da66a56954f881522e13
Contents?: true
Size: 896 Bytes
Versions: 29
Compression:
Stored size: 896 Bytes
Contents
# frozen_string_literal: true class Code GLOBALS = %i[output error context object].freeze DEFAULT_TIMEOUT = 0 def initialize( input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT ) @input = input @output = output @error = error @timeout = timeout || DEFAULT_TIMEOUT @context = Object::Context.new end def self.parse(input, timeout: DEFAULT_TIMEOUT) Timeout.timeout(timeout) { Parser.parse(input).to_raw } end def self.evaluate( input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT ) new(input, output:, error:, timeout:).evaluate end def evaluate Timeout.timeout(timeout) do parsed = Code.parse(input) Node::Code.new(parsed).evaluate(context:, output:, error:) end end private attr_reader :input, :timeout, :output, :error, :context end
Version data entries
29 entries across 29 versions & 1 rubygems