Class: WifiWand::Platforms::Selector

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

Overview

This class will be helpful in adding support for other OS's. To add an OS, see how each Selection::Base subclass is implemented, implement it, and add it to the list of supported OS's.

For the purpose of this program, an OS is defined as an approach to getting and setting WiFi information. Therefore, although Ubuntu and RedHat are both Linux, they will probably need separate Selection::Base subclasses.

Class Method Summary collapse

Class Method Details

.create_model_for_current_os(options = {}) ⇒ Object

Raises:



42
43
44
45
46
47
# File 'lib/wifi_wand/platforms/selector.rb', line 42

def create_model_for_current_os(options = {})
  current_os_instance = current_os
  raise NoSupportedOSError unless current_os_instance

  current_os_instance.create_model(options)
end

.current_display_nameObject



40
# File 'lib/wifi_wand/platforms/selector.rb', line 40

def current_display_name = current_os&.display_name

.current_idObject



38
# File 'lib/wifi_wand/platforms/selector.rb', line 38

def current_id = current_os&.id

.current_osObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/wifi_wand/platforms/selector.rb', line 27

def current_os
  @current_os ||= begin
    matches = supported_operating_systems.select(&:current_os_is_this_os?)
    if matches.size > 1
      matching_names = matches.map(&:display_name)
      raise MultipleOSMatchError, matching_names
    end
    matches.first # nil for an unrecognized OS
  end
end

.supported_operating_systemsObject



20
21
22
23
24
25
# File 'lib/wifi_wand/platforms/selector.rb', line 20

def supported_operating_systems
  @supported_operating_systems ||= [
    Selection::Mac.new,
    Selection::Ubuntu.new,
  ]
end