Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are forcing the Apple-installed Ruby to run, which is Ruby 1.8.7:</p> <pre><code>#!/usr/bin/ruby -w </code></pre> <p>instead of one of your Rubies managed by RVM. Try:</p> <pre><code>#!/usr/bin/env ruby -w </code></pre> <p>That way, if you want your system Ruby to run the code, you can tell RVM to switch to it:</p> <pre><code>rvm use system </code></pre> <p>and it will respond with: <code>Now using system ruby.</code> Alternately, you can use any of the RVM managed Rubies to run the code:</p> <pre><code>rvm 1.8.7 </code></pre> <p>if you had RVM install an instance of 1.8.7, or</p> <pre><code>rvm 1.9.2 </code></pre> <p>or</p> <pre><code>rvm default </code></pre> <p>if you set up a default Ruby for RVM, which is always a good idea:</p> <pre><code>rvm use 1.9.2 --default </code></pre> <p>You can check to see what versions of Ruby RVM has under its control:</p> <pre><code>$ rvm list rvm rubies ruby-1.8.7-p334 [ x86_64 ] =&gt; ruby-1.9.2-p180 [ x86_64 ] </code></pre> <p>Now, moving to your actual code, you have a bug. When trying to retrieve the price for an item you're looking for the wrong CSS, not finding the price node, getting a <code>nil</code> value, then trying to get the <code>text</code> from it. Use this instead:</p> <pre><code>price = item.at_css(".camelPrice").text[/\$[0-9\.]+/] </code></pre> <p>Your output will look similar to:</p> <pre> Fisher-Price Power Wheels Batman Lil Quad Ride-On - $59.97 /ip/Fisher-Price-Batman-Lil-Quad/10098697 </pre> <p>After making the change to the <code>#!</code> line, and the fix to the <code>price</code> line, I ran your code using Ruby 1.8.7 in my system, along with RVM controlled 1.8.7 and 1.9.2 with no problems.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload