class String

def ext(newext='')

+ext+ is a user added method for the String class.

is not given, or is the empty string, remove any existing extension.
the string, append the new extension to the end. If the new extension
Replace the file extension with +newext+. If there is no extension on
def ext(newext='')
  return self.dup if ['.', '..'].include? self
  if newext != ''
    newext = (newext =~ /^\./) ? newext : ("." + newext)
  end
  self.chomp(File.extname(self)) << newext
end