module ContactSync::StringPhone

Public Instance Methods

extract_country_code() click to toggle source
# File lib/contact_sync/util/string_phone.rb, line 10
def extract_country_code
  string = self
  if string[0..1] == "00"
    string[0..1] = "+"
  end
  if string[0] == "+"
    breakdown = GlobalPhone.parse(string)
    if breakdown.nil?
      return ["", string]
    end
    prefix = breakdown.country_code
    num = breakdown.national_string
    return [prefix,num]
  elsif string[0] == "0"
    num = string[1..-1]
    prefix = "0"
    return [prefix, num]
  else
    return ["", string]
  end
end
Also aliased as: format_phone_number
extract_encrypted_string_from_phone() click to toggle source

extend ActiveSupport::Concern

# File lib/contact_sync/util/string_phone.rb, line 6
def extract_encrypted_string_from_phone
  return self.extract_country_code.last.encrypt(:symmetric)
end
format_phone_number()