GithubHelp home page GithubHelp logo

isabella232 / street-address Goto Github PK

View Code? Open in Web Editor NEW

This project forked from instacart/street-address

0.0 0.0 0.0 126 KB

Detect, and dissect, US Street Addresses in strings.

License: MIT License

Ruby 100.00%

street-address's Introduction

Gem Version Build Status

DESCRIPTION

Parses a string returning a normalized Address object. When the string is not an US address it returns nil.

This is a port of the perl module Geo::StreetAddress::US originally written by Schuyler D. Erle.

Ruby Version

StreetAddress::US version 2+ is designed to work with ruby 2+. It may work with ruby 1.9.3, but will not work with ruby 1.8.x. If you need this to work pre ruby 2.0 please use gem version 1.0.6 or below.

Installation

    gem install StreetAddress

then in your code

    require 'street_address'

or from Gemfile

    gem 'StreetAddress', :require => "street_address"

Basic Usage

    require 'street_address'

    address = StreetAddress::US.parse("1600 Pennsylvania Ave, Washington, DC, 20500")
    address.street # Pennsylvania
    address.number # 1600
    address.postal_code # 20500
    address.city # Washington
    address.state # DC
    address.state_name # District of columbia
    address.street_type # Ave
    address.intersection? # false
    address.to_s # "1600 Pennsylvania Ave, Washington, DC 20500"
    address.to_s(:line1) # 1600 Pennsylvania Ave

    address = StreetAddress::US.parse("1600 Pennsylvania Ave") 
    address.street # Pennsylvania
    address.number # 1600
    address.state # nil

    address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 22303-1864")
    address.postal_code_ext # 1846
    address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 223031864")
    address.postal_code_ext # 1846

Stricter Parsing

    address = StreetAddress::US.parse_address("1600 Pennsylvania Avenue")
    # nil - not enough information to be a full address
    
    address = StreetAddress::US.parse_address("1600 Pennsylvania Ave, Washington, DC, 20500")
    # same results as above

License

The MIT Licencse

Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2014,2015 Derrek Long and Contributors

street-address's People

Contributors

derrek avatar schwern avatar skippy avatar opti avatar vlad-instacart avatar jsmith613 avatar amolk avatar ridiculous avatar

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.