module Pathname::Extensions::Ext
Changes extension of file
Public Class Methods
included(host)
click to toggle source
Calls superclass method
# File lib/pathname/extensions/ext.rb, line 9 def self.included(host) host.load_extensions :constants super end
Public Instance Methods
ext(new_extension = EMPTY_STRING)
click to toggle source
Replace the file extension with new_extension
. If there is no extension 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. @param new_extension [String] @return [Pathname]
# File lib/pathname/extensions/ext.rb, line 19 def ext(new_extension = EMPTY_STRING) return dup if [HERE, UPPER].include? self unless new_extension == EMPTY_STRING new_extension = '.' + new_extension unless new_extension.match?(/^\./) end sub_ext(new_extension) end