Skip to content

Instantly share code, notes, and snippets.

@aspencer8111
Created May 12, 2017 18:58
Show Gist options
  • Save aspencer8111/81386c47f266bfa39f151843faa39df2 to your computer and use it in GitHub Desktop.
Save aspencer8111/81386c47f266bfa39f151843faa39df2 to your computer and use it in GitHub Desktop.
Clean Slate Solution
def clean_slate(record, name)
name_array = name.split
record_words_array = record.split(' ')
first_name = name_array.first
last_name = name_array.last
first_name_downcased = first_name.downcase
last_name_downcased = last_name.downcase
new_record_array = []
record_words_array.each do |word|
if word == first_name or word == last_name or word == first_name_downcased or word == last_name_downcased
new_record_array << anonymize(name)
else
new_record_array << word
end
end
return new_record_array.join(' ')
end
def anonymize(name)
"X" * (name.length * 2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment