I'm trying to redefine the File.dirname method to first change %20s to spaces. But the following gives me an error
class File
   old_dirname = instance_method(:dirname)    
   define_method(:dirname) { |s|
       s = s.gsub("%20"," ")
       old_dirname.bind(self).call(s)
   }
end
This trhows a NameError exception: undefined method 'dirname' for class 'File'
What is the right way to do this?