Class: Judges::Eval
Overview
The eval
command.
This class is instantiated by the bin/judge
command line interface. You are not supposed to instantiate it yourself.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#initialize(loog) ⇒ Eval
constructor
A new instance of Eval.
- #run(_opts, args) ⇒ Object
Constructor Details
#initialize(loog) ⇒ Eval
Returns a new instance of Eval.
37 38 39 |
# File 'lib/judges/commands/eval.rb', line 37 def initialize(loog) @loog = loog end |
Instance Method Details
#run(_opts, args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/judges/commands/eval.rb', line 41 def run(_opts, args) raise 'Exactly two arguments required' unless args.size == 2 impex = Judges::Impex.new(@loog, args[0]) elapsed(@loog, level: Logger::INFO) do $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) throw :'Evaluated successfully' end end |