/phoney

Ruby library that parses a phone number and automatically formats it correctly, depending on the country/locale you set.

Primary LanguageRubyMIT LicenseMIT

phoney

This is a library for representing phone numbers. It provides a Phoney class that can format phone numbers depending on the region you set.

Installation

Gem

gem install phoney

Source

git clone git://github.com/habermann24/phoney.git

Feature overview

  • Create phone number by parsing a string

    require 'phoney'
    # region defaults to US
    Phoney.format("+17041234567")
    # => "+1 (704) 123-4567"
    
  • Deals with many specific region formatting rules (e.g. DE)

    require 'phoney'
    
    Phoney.region = :de
    
    Phoney.format("04105456789")
    # => "04105 456789"
    

TODOs

  • More tests for different countries