<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>greenideas &#187; code</title>
	<atom:link href="http://mwhenry.com/blog/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://mwhenry.com/blog</link>
	<description>A blog by Matt Henry</description>
	<lastBuildDate>Fri, 02 Jul 2010 23:26:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Stupid Ruby Problem</title>
		<link>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/</link>
		<comments>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 13:44:39 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=5</guid>
		<description><![CDATA[Like I said, I’m working on getting my Ruby chops up to snuff. I thought it might be fun to do that by porting all of the code in Joseph Adler’s fantastic Baseball Hacks from Perl to Ruby. I’m coming back to this project after letting it go for a while, and sure enough, the [...]]]></description>
			<content:encoded><![CDATA[<p>Like I said, I’m working on getting my Ruby chops up to snuff. I thought it might be fun to do that by porting all of the code in Joseph Adler’s fantastic <a href="http://books.google.com/books?id=51PS5G2Y2a4C&amp;dq=baseball+hacks&amp;pg=PP1&amp;ots=3YeuWSj5wn&amp;sig=J1V9kEnm1rtM1mD5_6sKtjFVRtQ&amp;hl=en&amp;prev=http://www.google.com/search?q=baseball+hacks&amp;ie=utf-8&amp;oe=utf-8&amp;rls=com.ubuntu:en-US:official&amp;client=firefox-a&amp;sa=X&amp;oi=print&amp;ct=title&amp;cad=one-book-with-thumbnail"><em>Baseball Hacks</em></a> from Perl to Ruby.</p>
<p>I’m coming back to this project after letting it go for a while, and sure enough, the problem I was having when I put it down is still vexing me.</p>
<p>One script is intended to grab all of the play-by-play data from <a href="http://retrosheet.org/">retrosheet.org</a>. The files all have urls like this:</p>
<pre class="code">

http://www.retrosheet.org/1957/1957al.zip

http://www.retrosheet.org/1957/1957nl.zip

http://www.retrosheet.org/1957/1957ml.zip</pre>
<p>The snippet below is a simplified version of the code I’m using to build the urls. It’s intended to print the urls of each zip file for each league from 1957 to  2006:</p>
<pre class="code">
year = 1957
leagues = ['al', 'nl', 'ml']leagues.each do |league|
  while year &lt;= 2006
    url = "http://www.retrosheet.org/#{year}/#{year}#{league}.zip"
    puts url
    year += 1
  end
end</pre>
<p>However, it doesn’t do that. It only generates the urls for the AL files, and I can’t get my brain around why.</p>
<p>I’ll be sure to add the solution when I figure it out, but for now I wanted to just document some of the struggles of a Ruby n00b.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

