title: undefined method `attr' for nil:NilClass (NoMethodError)
body: <p>I have a method in my CLI app which is giving me an error.</p>
  
  <p>The method is:</p>
  
  <pre><code>def self.deal_page(input, product_url)
      self.open_deal_page(input)
      deal = {}
      html = open(@product_url)
      doc = Nokogiri::HTML(html)
      data = doc.text.strip
      deal[:name] = doc.css("h1").text.strip
      deal[:discription] = doc.css(".textDescription").text.strip
      @purchase_link = nil
      @purchase_link= doc.at_css("div.detailLeftColumn a.success").attr("href")
          if @purchase_link.nil?
           deal[:purchase] = @product_url
         else
           deal[:purchase] = @purchase_link
         end
       deal
    end
  </code></pre>
  
  <p>and the error is:</p>
  
  <pre><code>/home/himachhag-45739/code/popular-deals-from-slickdeals.net-cli/lib/popular_deals/newdeals.rb:54:in `deal_page': undefined method `attr' for nil:NilClass (NoMethodError) 
          from /home/himachhag-45739/code/popular-deals-from-slickdeals.net-cli/lib/popular_deals/cli.rb:70:in `disply_deal'                                                 
          from /home/himachhag-45739/code/popular-deals-from-slickdeals.net-cli/lib/popular_deals/cli.rb:49:in `menu'                                                        
          from /home/himachhag-45739/code/popular-deals-from-slickdeals.net-cli/lib/popular_deals/cli.rb:9:in `call'                                                         
          from /home/himachhag-45739/code/popular-deals-from-slickdeals.net-cli/bin/popular-deals:10:in `&lt;top (required)&gt;'                                                   
          from /usr/local/rvm/gems/ruby-2.3.1/bin/popular-deals:22:in `load'                                                                                                 
          from /usr/local/rvm/gems/ruby-2.3.1/bin/popular-deals:22:in `&lt;main&gt;'                                                                                               
          from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'                                                                                         
          from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `&lt;main&gt;'
  </code></pre>
  
  <p>I tried <code>xpath</code>, <code>at_css</code>, <code>unless</code>, <code>if</code>..<code>else</code>, but doesn't help. Also, I don't get this error everytime, but I would like to get rid of it.</p>