Module: Himawari::NetUtils
- Included in:
- Download
- Defined in:
- lib/himawari/net_utils.rb
Overview
Network-related methods to help establish whether there is network access and figure out if we are on a possibly “metered” connection (via a hard-coded SSID blacklist)
Instance Method Summary collapse
-
#internet_connection? ⇒ DateTime
Checks our connection and as a bonus…
Instance Method Details
#internet_connection? ⇒ DateTime
Checks our connection and as a bonus…
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/himawari/net_utils.rb', line 10 def internet_connection? uid = now.to_i * 1_000 r = HTTParty.get("#{HIMAWARI_URL}/latest.json?uid=#{uid}", { timeout: 10 }) # puts "#{HIMAWARI_URL}/latest.json?uid=#{uid}" if verbose if r.code == 200 puts "Latest Himawari: #{r['date']}" if verbose @latest_remote = Time.parse("#{r['date']}+00:00") return true end false end |