Skip to content

Instantly share code, notes, and snippets.

@ewalk153
Created September 13, 2013 09:20
Show Gist options
  • Save ewalk153/6548423 to your computer and use it in GitHub Desktop.
Save ewalk153/6548423 to your computer and use it in GitHub Desktop.
Format and standardize parsing of phone numbers in our projects with this
def parse_phone(string)
(Phoner::Phone.parse(string) || Phoner::Phone.parse('+' + string) rescue 'failed')
end
def verify_phones
CSV.generate do |csv|
Trip.all.each do |t|
csv << [t.mobile, parse_phone(t.mobile)]
end
end
end
output = verify_phones; ''
File.open("./phones.csv", "w+").write(output)
# parse_phone '33 6.20.29.73.33'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment