Q:

Nokogiri check if value exists

I'm scraping some web stuff and I get the following error, 
scrape.rb:27:in block in <main>': undefined methodtext' for nil:NilClass (NoMethodError)
when running my ruby task, due to the css not containing any content inside.
Is there a way to check if CSS is not undefined so it wont stop crawling? My code wont work :(
products.each do |product|

     web = Nokogiri::HTML(open(product))

      counter = products.index(product)

      if web.at_css('.entry-title').text != undefined
      puts "CSS content is not undefined"
      else
      puts "Error"
      end

A:

You can just IF the object result before calling text
result = web.at_css('.entry-title')
if result
  puts "CSS content is not undefined"
  puts result.text
else
  puts "Error"
end

