Am 15.02.2014 01:36, schrieb cynic limbu:
> Cory Cory wrote in post #647411:
>> Does anyone know a way to test to see if the computer is connected to
>> the internet in Ruby?
> 
> Apologies for necro threading but let my answer help other people coming 
> to this link via google.
> 
> if system("ping google.com")
> puts "Connected to the internet."
> else puts "No internet connection."
> end

A more OS-independent solution would e.g. be using the net-ping gem:

  require 'net/ping'

  host = 'ruby-lang.org'
  Net::Ping::External.new(host).ping  # => true

Regards,
Marcus


-- 
GitHub: https://github.com/stomar/
PGP:    0x6B3A101A