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.



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

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.



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

def supported_operating_systems
  @supported_operating_systems
end

Instance Method Details

#current_display_nameObject



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

def current_display_name;  current_os ? current_os.display_name : nil;  end

#current_idObject



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

def current_id;            current_os ? current_os.id : nil;            end

#current_osObject



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

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 Error.new("There should only be 1 matching OS, but there were multiple: #{matching_names.inspect}")
    end
    @current_os = matches.first
  end
  @current_os
end