summaryrefslogtreecommitdiff
path: root/controllers/interfaces/eval.rb
blob: 5f472adc5da7a0d023b22d4409dbaec368e0f897 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

require 'pry'
require 'rainbow'

require_relative '../../logic/helpers/hash'
require_relative '../../logic/cartridge/affixes'

module NanoBot
  module Controllers
    module Interfaces
      module Eval
        def self.evaluate(input, cartridge, session, mode)
          prefix = Logic::Cartridge::Affixes.get(cartridge, mode.to_sym, :output, :prefix)
          suffix = Logic::Cartridge::Affixes.get(cartridge, mode.to_sym, :output, :suffix)

          session.print(prefix) unless prefix.nil?

          session.evaluate_and_print(input, mode:)

          session.print(suffix) unless suffix.nil?
        end
      end
    end
  end
end