daddyz / phonelib

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

get number without the country code #244

Closed jonchoi closed 2 years ago

jonchoi commented 2 years ago

phone = Phonelib.parse('+12122322234') phone.countrycode = '+1' phone.???? = '122322234' (without the '+1')

how do i do this?

jonchoi commented 2 years ago
image
jonchoi commented 2 years ago
image

NoMethodError (undefined method `country_code' for Phonelib:Module):

daddyz commented 2 years ago

@jonchoi here is how you can do it:

phone = Phonelib.parse('+12122322234')
phone.national # => "(212) 232-2234"
phone.national_number # => "2122322234"