Skip to content

Instantly share code, notes, and snippets.

@bdimcheff
Created July 15, 2009 00:35
Show Gist options
  • Save bdimcheff/147345 to your computer and use it in GitHub Desktop.
Save bdimcheff/147345 to your computer and use it in GitHub Desktop.
def parse_record
# Remove all non-digits from numeric attributes.
# Required in order to store data in Fannie Format
phones = %w{
borrower_ssn
borrower_phone_cell
borrower_phone_home
borrower_phone_work
borrower_employer_phone
coborrower_ssn
coborrower_phone_cell
coborrower_phone_home
coborrower_phone_work
coborrower_employer_phone
}
phones.each do |attribute|
# Cycle through each attribute, and remove non-digits from the string.
if self.send(attribute)
self.send("#{attribute}=", self.send(attribute).gsub(/[^0-9]/, "") }
else
self.send("#{attribute}=", "")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment