class Waps_mac

Public Class Methods

new() click to toggle source
# File lib/waps_mac.rb, line 5
def initialize
end

Public Instance Methods

parse(raw_input) click to toggle source
# File lib/waps_mac.rb, line 13
def parse(raw_input)
        cells = raw_input.split("\n")[1..-1]

        cells.map { |cell|  parse_cell(cell)}
end
parse_cell(cell) click to toggle source
# File lib/waps_mac.rb, line 25
def parse_cell(cell)
        raw_data = cell.split(" ")
        result = { 
                address: raw_data[1],
                channel: raw_data[3],
                signal_level: raw_data[2],
                encryption_key: pencryption_key(raw_data[6]),
                ssid: raw_data[0]
        }
end
pencryption_key(data) click to toggle source

Parse Values from the raw data. All methods below

# File lib/waps_mac.rb, line 39
def pencryption_key(data)
        data == "NONE" ? "off" : "On"
end
run_command() click to toggle source
# File lib/waps_mac.rb, line 19
def run_command
        output,error,status = Open3.capture3("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s")
        return output == "" ? {error: error} : {output: output}
end
scan() click to toggle source
# File lib/waps_mac.rb, line 8
def scan
        raw_input = run_command
        @output = (raw_input.keys.include? :error) ? raw_input : parse(raw_input[:output])
end