diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-13 13:50:31 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-13 13:50:31 +0000 |
commit | 70f25096c0c389888c06e0fea358c92153633b8e (patch) | |
tree | 0f172aee9a286081cc8ffd51bfd476c10ed56c67 /lib/pathname.rb | |
parent | 800ff52c17e0036a91bfc074db51e4222d0c7b8f (diff) | |
download | ruby-70f25096c0c389888c06e0fea358c92153633b8e.tar.gz |
* lib/pathname.rb (Pathname#sub_ext): new method. [ruby-list:44608]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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) |