gem install phony
This baby handles the world's phone numbers for you, in a nice and easy to use way.
Read more on the E164 recommendation which describes international phone number structure and functionality.
The (admittedly crazy) goal of this Gem is in the end to be able to handle all phone numbers in the world.
An austrian number, internationally formatted.
Phony.format('43198110', :format => :international, :spaces => :-).should == '+43-1-98110'
The french split numbers like that:
Phony.split('33112345678').should == ['33', '1', '12','34','56','78']
American formatting -> E164 normalized format.
Phony.normalize('1 (703) 451-5115').should == '17034515115'
Interested? There are more examples in the examples tab.