Module: PicoPhone

Defined in:
lib/pico_phone/phone_number.rb,
lib/pico_phone.rb,
lib/pico_phone/version.rb

Overview

Not loaded at runtime — exists only for YARD and IDE tooling. All methods are defined in ext/pico_phone/pico_phone.cpp via Rice.

Defined Under Namespace

Classes: Error, PhoneNumber

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.convert_alpha_characters(string) ⇒ String

Convert vanity number alpha characters to digits (e.g. "1-800-FLOWERS" → "1-800-3569377").

Parameters:

  • string (String)

Returns:

  • (String)


# File 'lib/pico_phone/phone_number.rb', line 73

.emergency_number?(string, region) ⇒ Boolean

Parameters:

  • string (String)
  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Boolean)


# File 'lib/pico_phone/phone_number.rb', line 54

.example_number(region) ⇒ PhoneNumber

Parameters:

  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:



# File 'lib/pico_phone/phone_number.rb', line 45

.example_number_for_type(region, type) ⇒ PhoneNumber

Parameters:

  • region (String)

    ISO 3166-1 alpha-2 region code

  • type (Symbol)

    e.g. :mobile, :fixed_line, :toll_free

Returns:



# File 'lib/pico_phone/phone_number.rb', line 49

.parse(string, region = nil) ⇒ PhoneNumber

Parse a phone number string into a PhoneNumber object.

Parameters:

  • string (String)

    raw phone number input

  • region (String, nil) (defaults to: nil)

    ISO 3166-1 alpha-2 region hint (e.g. "US")

Returns:



# File 'lib/pico_phone/phone_number.rb', line 7

.possible?(string) ⇒ Boolean

Parameters:

  • string (String)

Returns:

  • (Boolean)


# File 'lib/pico_phone/phone_number.rb', line 17

.possible_countries(string) ⇒ Array<String>

Regions that could own this number based on length or pattern.

Parameters:

  • string (String)

Returns:

  • (Array<String>)

    ISO 3166-1 alpha-2 region codes



# File 'lib/pico_phone/phone_number.rb', line 31

.possible_for_country?(string, region) ⇒ Boolean

Parameters:

  • string (String)
  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Boolean)


# File 'lib/pico_phone/phone_number.rb', line 26

.short_number_cost(string, region) ⇒ Symbol

Returns :toll_free, :standard_rate, :premium_rate, or :unknown_cost.

Parameters:

  • string (String)
  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Symbol)

    :toll_free, :standard_rate, :premium_rate, or :unknown_cost



# File 'lib/pico_phone/phone_number.rb', line 64

.short_number_valid?(string, region) ⇒ Boolean

Parameters:

  • string (String)
  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Boolean)


# File 'lib/pico_phone/phone_number.rb', line 59

.supported_regionsArray<String>

All region codes the library knows about (~245 in libphonenumber 9.x).

Returns:

  • (Array<String>)

    ISO 3166-1 alpha-2 region codes



# File 'lib/pico_phone/phone_number.rb', line 69

.supported_types_for_region(region) ⇒ Array<Symbol>

Parameters:

  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Array<Symbol>)


# File 'lib/pico_phone/phone_number.rb', line 41

.valid?(string) ⇒ Boolean

Parameters:

  • string (String)

Returns:

  • (Boolean)


# File 'lib/pico_phone/phone_number.rb', line 13

.valid_countries(string) ⇒ Array<String>

Regions for which this number passes strict pattern validation.

Parameters:

  • string (String)

Returns:

  • (Array<String>)

    ISO 3166-1 alpha-2 region codes



# File 'lib/pico_phone/phone_number.rb', line 36

.valid_for_country?(string, region) ⇒ Boolean

Parameters:

  • string (String)
  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Boolean)


# File 'lib/pico_phone/phone_number.rb', line 21