Class: WifiWand::Platforms::Mac::NetworkScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/wifi_wand/platforms/mac/network_scanner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(helper_client_provider:, system_profiler_wifi_data_reader:, system_profiler_wifi_data_cache_runner:, wifi_interface_provider:) ⇒ NetworkScanner

Returns a new instance of NetworkScanner.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wifi_wand/platforms/mac/network_scanner.rb', line 14

def initialize(
  helper_client_provider:,
  system_profiler_wifi_data_reader:,
  system_profiler_wifi_data_cache_runner:,
  wifi_interface_provider:
)
  @helper_client_provider = helper_client_provider
  @system_profiler_wifi_data_reader = system_profiler_wifi_data_reader
  @system_profiler_wifi_data_cache_runner = system_profiler_wifi_data_cache_runner
  @wifi_interface_provider = wifi_interface_provider
end

Class Method Details

.placeholder_network_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/wifi_wand/platforms/mac/network_scanner.rb', line 10

def self.placeholder_network_name?(name)
  SystemProfilerWifiDataNavigator.placeholder_network_name?(name)
end

Instance Method Details

#available_network_namesObject



26
27
28
# File 'lib/wifi_wand/platforms/mac/network_scanner.rb', line 26

def available_network_names
  scan.fetch('networks')
end

#helper_available_network_namesObject



45
46
47
48
49
# File 'lib/wifi_wand/platforms/mac/network_scanner.rb', line 45

def helper_available_network_names
  result = helper_client.scan_networks

  helper_available_network_names_from_result(result)
end

#scanObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/wifi_wand/platforms/mac/network_scanner.rb', line 30

def scan
  with_system_profiler_wifi_data_cache_scope do
    helper_result = helper_client.scan_networks
    helper_networks = helper_available_network_names_from_result(helper_result)
    return scan_result(helper_networks, source: 'mac_helper') if helper_networks

    fallback_networks = fallback_available_network_names
    if helper_result.location_services_blocked?
      return location_services_blocked_scan(fallback_networks)
    end

    scan_result(fallback_networks, source: 'fallback')
  end
end