def visited? url @visited ||=  return true if @visited.include? url @visited << url false end
Now I've got a
visited?method that tells me if I've called it already on an url
visited?('http://www.google.com') #=> false visited?('http://www.google.com') #=> true
That makes it easy to just do something like:
scrape(url) unless visited?(url)This was a short post but this is something I always put in my ruby code and I'll be referencing it later.