Created
May 12, 2017 18:58
-
-
Save aspencer8111/81386c47f266bfa39f151843faa39df2 to your computer and use it in GitHub Desktop.
Clean Slate Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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