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 problem I was having when I put it down is still vexing me.
One script is intended to grab all of the play-by-play data from retrosheet.org. The files all have urls like this:
http://www.retrosheet.org/1957/1957al.zip http://www.retrosheet.org/1957/1957nl.zip http://www.retrosheet.org/1957/1957ml.zip
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:
year = 1957
leagues = ['al', 'nl', 'ml']leagues.each do |league|
while year <= 2006
url = "http://www.retrosheet.org/#{year}/#{year}#{league}.zip"
puts url
year += 1
end
end
However, it doesn’t do that. It only generates the urls for the AL files, and I can’t get my brain around why.
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.