Class: Sheepsafe::Network
- Inherits:
-
Object
- Object
- Sheepsafe::Network
- Defined in:
- lib/sheepsafe/network.rb
Instance Attribute Summary collapse
-
#current_location ⇒ Object
readonly
Returns the value of attribute current_location.
Instance Method Summary collapse
- #bssid ⇒ Object
- #encrypted? ⇒ Boolean
-
#initialize(config = nil) ⇒ Network
constructor
A new instance of Network.
- #ssid ⇒ Object
- #trusted? ⇒ Boolean
- #trustworthy? ⇒ Boolean
- #untrusted? ⇒ Boolean
- #up? ⇒ Boolean
Constructor Details
#initialize(config = nil) ⇒ Network
Returns a new instance of Network.
5 6 7 8 9 |
# File 'lib/sheepsafe/network.rb', line 5 def initialize(config = nil) @current_location = `networksetup -getcurrentlocation`.chomp @data = YAML.load(`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I`.gsub(/^\s*([^:]+)/, '"\1"')) @config = config || Sheepsafe::Config.new({}) end |
Instance Attribute Details
#current_location ⇒ Object (readonly)
Returns the value of attribute current_location.
3 4 5 |
# File 'lib/sheepsafe/network.rb', line 3 def current_location @current_location end |
Instance Method Details
#bssid ⇒ Object
35 36 37 |
# File 'lib/sheepsafe/network.rb', line 35 def bssid @data['BSSID'] end |
#encrypted? ⇒ Boolean
23 24 25 |
# File 'lib/sheepsafe/network.rb', line 23 def encrypted? !(@data["802.11 auth"] == "open" or @data["link auth"] == "open") end |
#ssid ⇒ Object
31 32 33 |
# File 'lib/sheepsafe/network.rb', line 31 def ssid @data['SSID'] end |
#trusted? ⇒ Boolean
15 16 17 |
# File 'lib/sheepsafe/network.rb', line 15 def trusted? @config.trusted_names.include?(ssid) || @config.trusted_names.include?(bssid) end |
#trustworthy? ⇒ Boolean
11 12 13 |
# File 'lib/sheepsafe/network.rb', line 11 def trustworthy? !untrusted? && (encrypted? && @config.trust_encrypted? || trusted?) end |
#untrusted? ⇒ Boolean
19 20 21 |
# File 'lib/sheepsafe/network.rb', line 19 def untrusted? @config.untrusted_names.include?(ssid) || @config.untrusted_names.include?(bssid) end |
#up? ⇒ Boolean
27 28 29 |
# File 'lib/sheepsafe/network.rb', line 27 def up? @data['AirPort'] != false end |