Class: Paperclip::FilenameCleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip/filename_cleaner.rb

Instance Method Summary collapse

Constructor Details

#initialize(invalid_character_regex) ⇒ FilenameCleaner

Returns a new instance of FilenameCleaner



4
5
6
# File 'lib/paperclip/filename_cleaner.rb', line 4

def initialize(invalid_character_regex)
  @invalid_character_regex = invalid_character_regex
end

Instance Method Details

#call(filename) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/paperclip/filename_cleaner.rb', line 8

def call(filename)
  if @invalid_character_regex
    filename.gsub(@invalid_character_regex, "_")
  else
    filename
  end
end