From: Marc Haisenko Date: 2006-08-09T21:27:03+09:00 Subject: [PATCH] Pathname.to_a --Boundary-00=_TSd2EyMm63MlBlr Content-Type: Multipart/Mixed; boundary="Boundary-00=_TSd2EyMm63MlBlr" --Boundary-00=_TSd2EyMm63MlBlr Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline Hi folks, today I found myself wanting to get the parent directory name of a file, so I was looking whether Pathname has an to_a so I could do: parent_dir = path.to_a[-2] Since it didn't exist, I've written a small patch against CVS to add this simple function, maybe you find it useful :-) C'ya, Marc -- Marc Haisenko Comdasys AG R��desheimer Stra��e 7 D-80686 M��nchen Tel: �� +49 (0)89 - 548 43 33 21 Fax: �� +49 (0)89 - 548 43 33 29 e-mail: haisenko@comdasys.com http://www.comdasys.com --Boundary-00=_TSd2EyMm63MlBlr Content-Type: text/x-diff; charset="utf-8"; name="pathname-to_a.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pathname-to_a.patch" --- pathname.rb.orig 2006-07-08 10:56:27.000000000 +0200 +++ pathname.rb 2006-08-09 14:10:54.000000000 +0200 @@ -242,6 +242,13 @@ @path.dup end + # Return the path as an Array. + def to_a + a = @path.split SEPARATOR_PAT + a.shift if a[0].size == 0 + a + end + # to_path is implemented so Pathname objects are usable with File.open, etc. alias_method TO_PATH, :to_s --Boundary-00=_TSd2EyMm63MlBlr-- --Boundary-00=_TSd2EyMm63MlBlr--