Module: InternetConnection
- Defined in:
- lib/internet_connection.rb
Class Method Summary collapse
-
.off? ⇒ Boolean
exactly the opposite of on?.
-
.on? ⇒ Boolean
InternetConnection#on? will try to resolve google.com dns.
Class Method Details
.off? ⇒ Boolean
exactly the opposite of on?
26 27 28 |
# File 'lib/internet_connection.rb', line 26 def off? !on? end |
.on? ⇒ Boolean
InternetConnection#on? will try to resolve google.com dns. if it can you’ve got an internet connection
17 18 19 20 21 22 23 |
# File 'lib/internet_connection.rb', line 17 def on? begin !!Resolv.getaddress('www.google.com') rescue Errno::EHOSTUNREACH return false end end |