<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Temporarily change Ruby working directory</title>
	<atom:link href="http://www.dweebd.com/ruby/temporarily-change-ruby-working-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dweebd.com/ruby/temporarily-change-ruby-working-directory/</link>
	<description>Web Freshness</description>
	<lastBuildDate>Mon, 05 Jul 2010 23:44:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: duncanbeevers</title>
		<link>http://www.dweebd.com/ruby/temporarily-change-ruby-working-directory/comment-page-1/#comment-226</link>
		<dc:creator>duncanbeevers</dc:creator>
		<pubDate>Wed, 31 Dec 2008 08:05:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.dweebd.com/?p=147#comment-226</guid>
		<description>Thanks Mike,

I should have known when I wanted to do this that Ruby would do the logical thing when handed a block.  So nice!</description>
		<content:encoded><![CDATA[<p>Thanks Mike,</p>
<p>I should have known when I wanted to do this that Ruby would do the logical thing when handed a block.  So nice!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.dweebd.com/ruby/temporarily-change-ruby-working-directory/comment-page-1/#comment-224</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 31 Dec 2008 01:51:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.dweebd.com/?p=147#comment-224</guid>
		<description>Duncan,  you may not have realized that you can simplify this significantly as Dir.chdir already accepts a block:
&lt;code lang=&quot;ruby&quot;&gt;
def with_cwd dir
  Dir.chdir dir do
    yield  
  end
end
&lt;/code&gt;
It ensures that the current directory only changes for the context of the block. You can dispense with &#039;def with_cwd&#039; and inline it as it is no longer necessary.</description>
		<content:encoded><![CDATA[<p>Duncan,  you may not have realized that you can simplify this significantly as Dir.chdir already accepts a block:<br />
<pre class="ruby"><span class="kw1">def</span> with_cwd dir
  <span class="kw4">Dir</span>.<span class="me1">chdir</span> dir <span class="kw1">do</span>
    <span class="kw1">yield</span>  
  <span class="kw1">end</span>
<span class="kw1">end</span></pre><br />
It ensures that the current directory only changes for the context of the block. You can dispense with &#8216;def with_cwd&#8217; and inline it as it is no longer necessary.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic page generated in 0.343 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-08-02 13:36:45 -->

