daddyz / phonelib

Ruby gem for phone validation and formatting using google libphonenumber library data
MIT License
1.04k stars 130 forks source link

Add a getter for national_number #232

Closed frenesim closed 2 years ago

frenesim commented 3 years ago

Hi guys. How about exposing national_number as well?

I'm not able to get GB number as I would like to. For example:

phone = Phonelib.parse("447415153257")
phone.national # "07415 153257"

I would like to have it without the leading 0. Parsing it would cause a problem when we have other countries like:

phone = Phonelib.parse("+22508022052", "CI")
phone.national  # "08 02 20 52"

For this one the leading '0' is not optional, without it the number is invalid.

I'm available to improve this PR with your suggestions if you are keen to go along.