Class: Judges::Eval

Inherits:
Object show all
Defined in:
lib/judges/commands/eval.rb

Overview

Eval.

Author

Yegor Bugayenko (yegor256@gmail.com)

Copyright

Copyright © 2024 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(loog) ⇒ Eval

Returns a new instance of Eval.



36
37
38
# File 'lib/judges/commands/eval.rb', line 36

def initialize(loog)
  @loog = loog
end

Instance Method Details

#run(_opts, args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/judges/commands/eval.rb', line 40

def run(_opts, args)
  raise 'Exactly two arguments required' unless args.size == 2
  impex = Judges::Impex.new(@loog, args[0])
  $fb = impex.import(strict: false)
  $fb = Factbase::Looged.new($fb, @loog)
  expr = args[1]
  # rubocop:disable Security/Eval
  eval(expr)
  # rubocop:enable Security/Eval
  impex.export($fb)
end