タグ

ブックマーク / cyll.org (1)

  • Lessons From Hpricot

    HTML processing, C parser, yada, yada, yada. What lesson did I actually learn from Hpricot? Abuse the / operator! Why, the Lucky Stiff, presents this neat bit of code: doc = Hpricot.parse(File.read("index.html")) (doc/:p/:a).each do |link| p link.attributes end Nice! That's hot. Let's run with this for a moment and add / navigation to hashes. class Hash def /(key) self[key] end end people = {:toph

  • 1