Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def full_search(offensive_list)
- p 'Full check:'
- p "Comparing #{$all_vehicles.count} records against #{offensive_list.count} banned combinations"
- p 'This will take a few minutes'
- vrm_array, example_array = [], []
- vrm_list = $all_vehicles.keys.sort
- vrm_list.each do |vrm|
- vrm_array << vrm.split("") #We split each reg into an array of characters
- end
- offensive_list.each do |example|
- example.strip!
- example_array << example.split("") #and the same with our banned combinations
- end
- vrm_array.each do |vrm|
- example_array.each do |example| #itterate through vrms x examples
- @formatted_vrm = vrm.dup
- if example.length == vrm.length
- example.each_index do |index|
- if example[index] == "?" #for each wildcard we add a wildcard to the vrm for comparison
- @formatted_vrm[index] = "?"
- end
- end
- if @formatted_vrm == example then offensive_found(vrm, example) end
- end
- end
- end
- end
- def offensive_found(vrm, example)
- built_vrm = ""
- built_example = ""
- if vrm.class == Array #clean up formatting so we can store it
- vrm.each do |character|
- built_vrm << character
- end
- example.each do |character|
- built_example << character
- end
- else
- built_example = example #clearly redundant, but it works so...
- built_vrm = vrm
- end
- if $bad_vrms[built_example] # if we already have a record
- prev_matched = $bad_vrms[built_example] #just add to the array
- prev_matched << built_vrm
- $bad_vrms.store(built_example, prev_matched)
- else
- new_match = [built_vrm] # or create a new hash key
- $bad_vrms.store(built_example, new_match)
- end
- #p "#{built_vrm} - matched with #{built_example}"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement