Class: Y2Network::WirelessNetwork
- Inherits:
-
Object
- Object
- Y2Network::WirelessNetwork
- Defined in:
- src/lib/y2network/wireless_network.rb
Overview
Each instance of this class represents a wireless network
Instance Attribute Summary collapse
-
#auth_mode ⇒ Object
readonly
Returns the value of attribute auth_mode.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#essid ⇒ Object
readonly
Returns the value of attribute essid.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
-
#rates ⇒ Object
readonly
Returns the value of attribute rates.
Class Method Summary collapse
-
.all(iface_name, cache: true) ⇒ Object
Returns the wireless networks found through a given interface.
Instance Method Summary collapse
-
#initialize(essid:, mode:, channel:, rates:, quality:, auth_mode:) ⇒ WirelessNetwork
constructor
Constructor.
Constructor Details
#initialize(essid:, mode:, channel:, rates:, quality:, auth_mode:) ⇒ WirelessNetwork
Constructor
54 55 56 57 58 59 60 61 |
# File 'src/lib/y2network/wireless_network.rb', line 54 def initialize(essid:, mode:, channel:, rates:, quality:, auth_mode:) @essid = essid @mode = mode @channel = channel @rates = rates @quality = quality @auth_mode = auth_mode end |
Instance Attribute Details
#auth_mode ⇒ Object (readonly)
Returns the value of attribute auth_mode.
26 27 28 |
# File 'src/lib/y2network/wireless_network.rb', line 26 def auth_mode @auth_mode end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
26 27 28 |
# File 'src/lib/y2network/wireless_network.rb', line 26 def channel @channel end |
#essid ⇒ Object (readonly)
Returns the value of attribute essid.
26 27 28 |
# File 'src/lib/y2network/wireless_network.rb', line 26 def essid @essid end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
26 27 28 |
# File 'src/lib/y2network/wireless_network.rb', line 26 def mode @mode end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
26 27 28 |
# File 'src/lib/y2network/wireless_network.rb', line 26 def quality @quality end |
#rates ⇒ Object (readonly)
Returns the value of attribute rates.
26 27 28 |
# File 'src/lib/y2network/wireless_network.rb', line 26 def rates @rates end |
Class Method Details
.all(iface_name, cache: true) ⇒ Object
Returns the wireless networks found through a given interface
If there is more than one AP, it selects the one with higher signal quality.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'src/lib/y2network/wireless_network.rb', line 34 def all(iface_name, cache: true) @all ||= {} return @all[iface_name] if cache && @all[iface_name] cells = WirelessScanner.new(iface_name).cells known_essids = cells.map(&:essid).uniq @all[iface_name] = known_essids.map do |essid| preferred_cell = cells .select { |c| c.essid == essid } .max_by { |c| c.quality.to_i } attrs = preferred_cell.to_h attrs.delete(:address) Y2Network::WirelessNetwork.new(**attrs) end end |