Method: Phonelib::PhoneFormatter#area_code

Defined in:
lib/phonelib/phone_formatter.rb

#area_codeString|nil

returns area code of parsed number

Returns:

  • (String|nil)

    parsed phone area code if available



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/phonelib/phone_formatter.rb', line 100

def area_code
  return nil unless area_code_possible?

  format_match, _format_string = formatting_data
  take_group = 1
  if type == Core::MOBILE && Core::AREA_CODE_MOBILE_TOKENS[country] && \
     format_match[1] == Core::AREA_CODE_MOBILE_TOKENS[country]
    take_group = 2
  end
  format_match[take_group]
end