David Cantrell > Number-Phone > Number::Phone::NANP

Download:
Number-Phone-3.3000.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.5   Source  

NAME ^

Number::Phone::NANP - NANP-specific methods for Number::Phone

DESCRIPTION ^

This is a base class which encapsulates that information about phone numbers in the North American Numbering Plan (NANP) which are common to all NANP countries - that is, those whose international dialling code is +1.

Country-specific modules should inherit from this module and provide their own versions of methods as necessary. However, they should not provide an is_valid method or a constructor.

SYNOPSIS ^

This module should not be used directly. It will be loaded as necessary by Number::Phone:

    use Number::Phone;

    my $phone_number = Number::Phone->new('+1 202 418 1440');
    # $phone_number is now a Number::Phone::NANP::US

    my $other_phone_number = Number::Phone->new('+1 866 623 2282');
    # $phone_number is non-geographic so is a Number::Phone::NANP

METHODS ^

The following methods from Number::Phone are overridden:

new

The constructor, you should never have to call this yourself. To create an object the canonical incantation is Number::Phone-new('+1 ...')>.

is_valid

The number is valid within the numbering scheme. It may or may not yet be allocated, or it may be reserved.

is_geographic

NANP-globals like 1-800 aren't geographic, the rest are.

is_mobile

NANP-globals like 1-800 aren't mobile. For most others we just don't know because the data isn't published. libphonenumber has data for *some* countries, so we use that if we can.

is_fixed_line

NANP-globals are fixed lines, for the rest we generally don't know with some exceptions as per is_mobile above.

is_drama

The number is a '555' number. Numbers with the D, E, and F digits set to 555 are not allocated to real customers, and are intended for use in fiction. eg 212 555 2368 for Ghostbusters.

NB, despite Ghostbusters above, only 555-0100 to 555-0199 are actually reserved.

is_tollfree

The number is free to the caller. 800, 844, 855, 866, 877 and 888 "area codes"

is_specialrate

The number is charged at a higher rate than normal. The 900 "area code".

is_personal

The number is a "personal" number. The 500, 533, 544, 566 and 577 "area codes".

country_code

Returns 1.

regulator

Returns informational text relevant to the whole NANP. Note that when this method is inherited by a subclass it returns undef meaning "not known", but returns information about the NANPA when called on an object of class Number::Phone::NANP.

areacode

Return the area code for the number.

areaname

Return the name for the area code, if applicable, otherwise returns undef. For instance, for a number beginning with +1 201 200 it would return "Jersey City, NJ".

subscriber

Return the subscriber part of the number.

format

Return a sanely formatted version of the number, complete with IDD code.

BUGS/FEEDBACK ^

Please report bugs at https://github.com/DrHyde/perl-modules-Number-Phone/issues, including, if possible, a test case.

I welcome feedback from users.

LICENCE ^

You may use, modify and distribute this software under the same terms as perl itself.

AUTHOR ^

David Cantrell <david@cantrell.org.uk>

Copyright 2012

syntax highlighting: