Check if Internet Connection Exists with Ruby? <p>Just asked how to <a href="http://stackoverflow.com/questions/2384167/check-if-internet-connection-exists-with-javascript">check if an internet connection exists using javascript</a> and got some great answers. What's the easiest way to do this in Ruby? In trying to make generated html markup code as clean as possible, I'd like to conditionally render the script tag for javascript files depending on whether or not an internet condition. Something like (this is HAML):</p> <pre><code>- if internet_connection? %script{:src =&gt; "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", :type =&gt; "text/javascript"} - else %script{:src =&gt; "/shared/javascripts/jquery/jquery.js", :type =&gt; "text/javascript"} </code></pre>