module BatchExperiment::FnameSanitizer
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).
Public Class Methods
Returns a copy of the argument where each sequence of non-alphanumeric characters were changed to one single underscore ('_'), remove trailing underscores at the beggining and the end of the string.
@param command [String] A command to be sanitized. @return [String] The sanitized command.
# File lib/batch_experiment.rb, line 33 def self.call(command) fname = command.strip fname.gsub!(/[^[:alnum:]]/, '_') fname.gsub!(/_+/, '_') fname.gsub!(/^_/, '') fname.gsub!(/_$/, '') fname end