Giter Site home page Giter Site logo

dialable's Introduction

dialable

A gem that provides parsing and output of phone numbers according to NANPA standards.

Phone numbers are not a big deal if you can validate the input at the time you’ve got a human right there. My enterprise tends not to have that ability, as we receive large files from clients with little or no validation done. Rather than abandon #s which don’t validate, I wrote this to parse and normalize a string into a standard NANP phone number, possibly including an extension.

References: NANPA: North American Numbering Plan Administration nanpa.com/

The YAML file with the valid area codes and easily recognizable codes (like 911) can get out of date. To update your own copy, run:

support/make_yaml_nanpa.rb > data/nanpa.yaml

require “dialable”

pn = Dialable::NANP.parse(“+1(800)555-1212 ext 1234”)

>> puts pn.to_s // Pretty output

800-555-1212 x1234

>> puts pn.to_digits // Address book friendly

8005551212 x1234

>> puts pn.to_dialable // PBX friendly

8005551212

>> puts pn.extension

1234

Also, pn.timezones and pn.relative_timezones should do the right thing.

-chorn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.