Module: ConSync::StringPhone

Defined in:
lib/con_sync/util/string_phone.rb

Instance Method Summary collapse

Instance Method Details

#extract_country_codeObject

extend ActiveSupport::Concern



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/con_sync/util/string_phone.rb', line 6

def extract_country_code
  string = self
  if string[0..1] == "00"
    string[0..1] = "+"
  end
  if string[0] == "+"
    breakdown = GlobalPhone.parse(string)
    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