Replace the file extension with newext. If there is no extenson on the string, append the new extension to the end. If the new extension is not given, or is the empty string, remove any existing extension.
ext is a user added method for the String class.
Source Code
# File rake.rb, line 80 def ext(newext='') return self.dup if ['.', '..'].include? self if newext != '' newext = (newext =~ /^\./) ? newext : ("." + newext) end dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext end
<code/>and<pre/>for code samples.