diff options
Diffstat (limited to 'lib/pathname.rb')
-rw-r--r-- | lib/pathname.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/pathname.rb b/lib/pathname.rb index e4ca5489ce..b2e119db11 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -255,11 +255,22 @@ class Pathname end if File::ALT_SEPARATOR - SEPARATOR_PAT = /[#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}]/ + SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}" + SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/ else + SEPARATOR_LIST = "#{Regexp.quote File::SEPARATOR}" SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/ end + # Return a pathname which the extention of the basename is substituted by + # <i>repl</i>. + # + # If self has no extension part, <i>repl</i> is appended. + def sub_ext(repl) + ext = File.extname(@path) + self.class.new(@path.chomp(ext) + repl) + end + # chop_basename(path) -> [pre-basename, basename] or nil def chop_basename(path) base = File.basename(path) |