Last Updated: February 25, 2016
·
590
· jayfajardo

Check for internet connection in Macruby

Checking for internet connectivity in a Macruby app is dead simple.

class MyConnection

  require 'socket'

  def has_connection?
    !Socket.getaddrinfo('google.com', nil).empty?
  rescue
    false
  end

end