Class: WifiWand::OperatingSystems

Inherits:
Object
  • Object
show all
Defined in:
lib/wifi-wand/operating_systems.rb

Overview

This class will be helpful in adding support for other OS’s. To add an OS, see how each BaseOs 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 BaseOs subclasses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOperatingSystems

Returns a new instance of OperatingSystems.



21
22
23
24
25
26
# File 'lib/wifi-wand/operating_systems.rb', line 21

def initialize
  @supported_operating_systems = [
      ImaginaryOs.new,
      MacOs.new
  ]
end

Instance Attribute Details

#supported_operating_systemsObject (readonly)

Returns the value of attribute supported_operating_systems.



18
19
20
# File 'lib/wifi-wand/operating_systems.rb', line 18

def supported_operating_systems
  @supported_operating_systems
end

Instance Method Details

#current_display_nameObject



43
# File 'lib/wifi-wand/operating_systems.rb', line 43

def current_display_name;  current_os&.display_name;  end

#current_idObject



42
# File 'lib/wifi-wand/operating_systems.rb', line 42

def current_id;            current_os&.id;            end

#current_osObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/wifi-wand/operating_systems.rb', line 29

def current_os
  if @current_os.nil?
    matches = supported_operating_systems.select { |os| os.current_os_is_this_os? }
    if matches.size > 1
      matching_names = matches.map(&:display_name)
      raise "There should only be 1 matching OS, but there were multiple: #{matching_names.inspect}"
    end
    @current_os = matches.first
  end
  @current_os
end