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

+ (Object) call(filename)

downcase and replace all non-alphanumerics with '_'



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

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