require "./company" class Analyzer def initialize(file="macscan.csv") @raw = File.readlines(file).map{|l| l.chomp} interesting = false @stations = @raw.select{|l| if l=~/^Station MAC, / interesting = true false elsif l=~/^BSSID,/ interesting = false else interesting && l.size>0 end } @data = @stations.map{|l| l.scan(/([0-9A-F:]{17}),\s+([^,]+),\s+([^,]+)/)[0] }.select{|l| l} @data.map!{|e| t = e[1].split(/[: -]/).map{|x| x.to_i} e[1] = Time.new(*t) t = e[2].split(/[: -]/).map{|x| x.to_i} e[2] = Time.new(*t) e } @data.sort!{|a,b| a[1]<=>b[1]} @comp = Company.new @data.map{|e| e[3]=@comp.get_company(e[0]); e} end def companys macs = @data.map{|e| e[0]}.sort.uniq macs.map{|m| @comp.get_company(m)} end def oneMinute num = [] pos = 0 first = @data[pos][1] seen = [@data[pos][0]] while (pos<@data.size) first += 60 pos+=1 while (pos<@data.size && @data[pos][1]