Class: WifiWand::OperatingSystems
- Inherits:
-
Object
- Object
- WifiWand::OperatingSystems
- 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
-
#supported_operating_systems ⇒ Object
readonly
Returns the value of attribute supported_operating_systems.
Instance Method Summary collapse
- #current_display_name ⇒ Object
- #current_id ⇒ Object
- #current_os ⇒ Object
-
#initialize ⇒ OperatingSystems
constructor
A new instance of OperatingSystems.
Constructor Details
#initialize ⇒ OperatingSystems
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_systems ⇒ Object (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 end |
Instance Method Details
#current_display_name ⇒ Object
44 |
# File 'lib/wifi-wand/operating_systems.rb', line 44 def current_display_name; current_os ? current_os.display_name : nil; end |
#current_id ⇒ Object
43 |
# File 'lib/wifi-wand/operating_systems.rb', line 43 def current_id; current_os ? current_os.id : nil; end |
#current_os ⇒ Object
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 = .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 |