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



30
31
32
33
# File 'lib/phonelib/phone_extended_data.rb', line 30

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



14
15
16
17
# File 'lib/phonelib/phone_extended_data.rb', line 14

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



22
23
24
25
# File 'lib/phonelib/phone_extended_data.rb', line 22

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

#valid_country_nameObject

returns valid country name



36
37
38
39
40
# File 'lib/phonelib/phone_extended_data.rb', line 36

def valid_country_name
  return unless valid?

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