Method: MacWifi::MacOsModel#wifi_info

Defined in:
lib/mac-wifi/mac_os_model.rb

#wifi_infoObject

Returns some useful wifi-related information.



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/mac-wifi/mac_os_model.rb', line 251

def wifi_info

  info = {
      'wifi_on'     =>    wifi_on?,
      'internet_on' => connected_to_internet?,
      'port'        => wifi_hardware_port,
      'network'     => current_network,
      'ip_address'  => ip_address,
      'nameservers' => nameservers,
      'timestamp'   => Time.now,
  }
  more_output = run_os_command(AIRPORT_CMD + " -I")
  more_info   = colon_output_to_hash(more_output)
  info.merge!(more_info)
  info.delete('AirPort') # will be here if off, but info is already in wifi_on key

  if info['wifi_on']
    begin
      info['public_ip'] = public_ip_address_info
    rescue => e
      puts "Error obtaining public IP address info, proceeding with everything else:"
      puts e.to_s
    end
  end
  info
end