Module: ContactSync::StringPhone

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

Instance Method Summary collapse

Instance Method Details

#extract_country_codeObject Also known as: format_phone_number



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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

#extract_encrypted_string_from_phoneObject

extend ActiveSupport::Concern



6
7
8
# 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