Class: Utilities::CleanseFilename

Inherits:
Object
  • Object
show all
Defined in:
lib/utilities/cleanse_filename.rb

Overview

TODO: This needs to be in /lib

Class Method Summary collapse

Class Method Details

.call(filename) ⇒ String

downcase and replace all non-alphanumerics with ‘_’

Parameters:

  • filename (String)

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/utilities/cleanse_filename.rb', line 12

def self.call(filename)
 filename.to_s.downcase.gsub(/[^A-Za-z0-9\.]/, '_')

#tmp = (filename.to_s.downcase).split('.')
#if tmp.count == 2
#   tmp[0].gsub(/[^A-Za-z0-9\.]/, '_') + '.' + tmp[1]
#else
# for i in 0..(tmp.length-1)
#    name = tmp[i].gsub(/[^A-Za-z0-9\.]/, '_')
#  end
#  name.join('_') + '.' + tmp.last
#end
end