Class: Judges::Trim
Overview
The trim
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) ⇒ Trim
constructor
A new instance of Trim.
-
#run(opts, args) ⇒ Object
Run it (it is supposed to be called by the
bin/judges
script..
Constructor Details
#initialize(loog) ⇒ Trim
Returns a new instance of Trim.
37 38 39 |
# File 'lib/judges/commands/trim.rb', line 37 def initialize(loog) @loog = loog end |
Instance Method Details
#run(opts, args) ⇒ Object
Run it (it is supposed to be called by the bin/judges
script.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/judges/commands/trim.rb', line 44 def run(opts, args) raise 'Exactly one argument required' unless args.size == 1 impex = Judges::Impex.new(@loog, args[0]) fb = impex.import elapsed(@loog, level: Logger::INFO) do deleted = fb.query(opts['query']).delete! throw :'No facts deleted' if deleted.zero? impex.export(fb) throw :"🗑 #{deleted} fact(s) deleted" end end |