From 9bfb4dc6ac6815aa600575c8745870b6ee8f9f91 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 23 Sep 2005 23:32:29 +0000 Subject: [PATCH] * lib/pathname.rb (Pathname#sub): new method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/pathname.rb | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index de7833d9ec..bbb7549d00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Sep 24 08:30:00 2005 Tanaka Akira + + * lib/pathname.rb (Pathname#sub): new method. + Sat Sep 24 08:29:36 2005 Minero Aoki * lib/fileutils.rb: fix visibility of FileUtils::NoWrite, Verbose, diff --git a/lib/pathname.rb b/lib/pathname.rb index 7b371def2b..e4e2b01992 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -235,7 +235,11 @@ class Pathname "#<#{self.class}:#{@path}>" end - # + # Return a pathname which is substituted by String#sub. + def sub(pattern, *rest, &block) + Pathname.new(@path.sub(pattern, *rest, &block)) + end + # Returns clean pathname of +self+ with consecutive slashes and useless dots # removed. The filesystem is not accessed. # @@ -438,6 +442,8 @@ class Pathname # # # # # + # It doesn't access actual filesystem. + # def descend paths = [] v = self @@ -473,6 +479,8 @@ class Pathname # # # # # + # It doesn't access actual filesystem. + # def ascend paths = [] v = self