I have the following code:
address = "#{(article/"div.address").inner_html.strip_html.squish}"
(using Hpricot)
And in some instances…
address = "#{(article/"div.address").inner_html.strip_html.squish}"
…is nil
I would like the script to keep chugging along, possibly replacing nil with an empty string.
Any tips?
Edit
I have traced the problem better to:
puts "#{link[0].to_s}\n" unless link.empty?
(.backtrace points to this particular line in the source.)
So the revised question is: why doesn’t that line just not get parsed? Why does it throw an error? I thought that using unless will just skip it…
Thank you all for the support and helpful tips, in the end it was a matter of using the proper method, I ended up solving my problem by using:
unless uri.query.nil?But I did come to make use of both
.to_sandtryin my source, and I wish I could pick two answers as the right one!