From 991bae91a9f4956df1cda56d5e5586e567b05f7a Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sat, 27 Feb 2010 12:29:45 +0000 Subject: [PATCH] Pathname.subdirs and Pathname.cd{} --- Library/Homebrew/extend/pathname.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 698136fcb1..0cff35c8a9 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -167,6 +167,14 @@ class Pathname if '1.9' <= RUBY_VERSION alias_method :to_str, :to_s end + + def cd + Dir.chdir(self){ yield } + end + + def subdirs + children.select{ |child| child.directory? } + end end # sets $n and $d so you can observe creation of stuff