Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Figure out how a number should be dialed from another country
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
resources
tasks
test
.gitignore
.rvmrc
.travis.yml
Gemfile
Guardfile
LICENSE
README.md
Rakefile
VERSION
as_dialed_from.gemspec

README.md

as_dialed_from Build Status

Figure out how a number should be dialed from another country. A fork of a port of Google's libphonenumber.

Warning

Not all country combinations work correctly. Contributions welcome.

Examples

as_dialed_from prototypes the String class with an as_dialed_from method.

require 'as_dialed_from'

"+12155551212".as_dialed_from "US"
 => "12155551212"

"+12155551212".as_dialed_from 52 # Mexico
 => "0012155551212"

"+12155551212".as_dialed_from "74957285000" # Russia
 => "8~1012155551212"

The "from" argument can be one of many things

  • An ISO 3166-2 code ("US")
  • Any valid country code digits, as an Integer (1) or String ("1")
  • If a phone number is passed, it will try to find the country code for that number ("12155551212")

Installing

Shell

gem install as_dialed_from

Gemfile

gem 'as_dialed_from'

And then bundle install

Something went wrong with that request. Please try again.