Module: Phonelib::PhoneExtendedData

Included in:
Phone
Defined in:
lib/phonelib/phone_extended_data.rb

Overview

module provides extended data methods for parsed phone

Constant Summary collapse

EXT_KEYS =
[
  Phonelib::Core::EXT_GEO_NAME_KEY,
  Phonelib::Core::EXT_TIMEZONE_KEY,
  Phonelib::Core::EXT_CARRIER_KEY
]

Instance Method Summary collapse

Instance Method Details

#carrierString|nil

Returns carrier of parsed phone number or nil if number is invalid or there is no carrier specified in db for this number

Returns:

  • (String|nil)

    carrier for parsed phone



32
33
34
35
# File 'lib/phonelib/phone_extended_data.rb', line 32

def carrier
  get_ext_name Phonelib::Core::EXT_CARRIERS,
               Phonelib::Core::EXT_CARRIER_KEY
end

#geo_nameString|nil

Returns geo name of parsed phone number or nil if number is invalid or there is no geo name specified in db for this number

Returns:

  • (String|nil)

    geo name for parsed phone



16
17
18
19
# File 'lib/phonelib/phone_extended_data.rb', line 16

def geo_name
  get_ext_name Phonelib::Core::EXT_GEO_NAMES,
               Phonelib::Core::EXT_GEO_NAME_KEY
end

#timezoneString|nil

Returns timezone of parsed phone number or nil if number is invalid or there is no timezone specified in db for this number

Returns:

  • (String|nil)

    timezone for parsed phone



24
25
26
27
# File 'lib/phonelib/phone_extended_data.rb', line 24

def timezone
  get_ext_name Phonelib::Core::EXT_TIMEZONES,
               Phonelib::Core::EXT_TIMEZONE_KEY
end

#valid_country_nameObject

returns valid country name



38
39
40
41
42
# File 'lib/phonelib/phone_extended_data.rb', line 38

def valid_country_name
  return unless valid?

  Phonelib.phone_ext_data[Phonelib::Core::EXT_COUNTRY_NAMES][valid_country]
end