From: Brad Ediger Date: 2007-08-27T04:50:05+09:00 Subject: Re: [QUIZ] [SOLUTION] ID3 Tags (#136) On Aug 26, 2007, at 2:40 PM, Ken Bloom wrote: > On Mon, 27 Aug 2007 02:32:05 +0900, Brad Ediger wrote: > >> One of the biggest problems in software development is feature >> creep. In >> the case of this Quiz, specification creep was the culprit, with the >> spec being changed two times in two days. No offense intended, >> JEG2 ;-) >> >> Luckily, we can use the mighty power of Ruby to make our application >> impervious to such changes, and save a couple heredocs to boot. >> >> ------------------------- >> >> #!/usr/bin/env ruby -rubygems >> >> %w(hpricot open-uri).each(&method(:require)) >> >> fields, genres = (Hpricot(open("http://www.rubyquiz.com/ >> quiz136.html")) / "p.example").map{|e| e.inner_html} >> fields = fields.split >> genres = genres.split "
" > > You hard-coded the value of the unpack field. I know, I felt bad about doing it (and this was more of a "ha-ha, have fun with the Quiz" submission than a "use this in production" submission). I was about to rewrite it to scrape the actual data structure from the table in http://www.id3.org/ID3v1, but then I'd have to find another quasi-official source for the genre list, and it began to feel more like work. I like your solution. Yes, I should have used a "c" for the genre field, but my brain wasn't working. -be