Module: BatchExperiment::FnameSanitizer
- Defined in:
- lib/batch_experiment.rb
Overview
The default callable object used by Comm2FnameConverter to convert a command into a filename. Comm2FnameConverter don’t create a sanitized filename from the command string (it uses its first argument to do this, whose default is FnameSanitizer). Note that this is a pure function, so if the same command appears more than one time, it will get the same name, it’s Comm2FnameConverter that gives multiple instances of the same command different names (by suffixing with numbers).
Class Method Summary collapse
Class Method Details
.call(command) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/batch_experiment.rb', line 16 def self.call(command) fname = command.strip fname.gsub!(/[^[:alnum:]]/, '_') fname.gsub!(/_+/, '_') fname.gsub!(/^_/, '') fname.gsub!(/_$/, '') fname end |