User defined methods to be added to String.
Methods
Public Instance methods
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.
[ show source ]
# File lib/rake.rb, line 73 73: def ext(newext='') 74: return self.dup if ['.', '..'].include? self 75: if newext != '' 76: newext = (newext =~ /^\./) ? newext : ("." + newext) 77: end 78: dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext 79: end