1k0izw
Last Updated: February 25, 2016
·
395
· 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