require 'open-uri' #require 'net/http' require 'timeout' class Internet @@available=true def self.available? return @@available if !@@available.nil? begin index=open('http://www.google.com').read if index.include?('Google') @@available = true else puts "open('http://www.google.com') returned false" end rescue Exception => e puts "open('http://www.google.com') raised an exception: #{e.to_s}" @@available = false end @@available end end