Code Monkey home page Code Monkey logo

people_places_things's Introduction

PeoplePlacesThings

PeoplePlacesThings is a collection of ruby classes for parsing and formatting U.S person names, street addresses, phone numbers, and more.

gem install -s http://gemcutter.org people_places_things

Rdocs available at http://rdoc.info/projects/dburkes/people_places_things

Using PeoplePlacesThings


  require 'people_places_things'
  include PeoplePlacesThings

  name = PersonName.new("george quincy harold peabody jr.")
  name.first => "george"
  name.first_i => "g"
  name.last => "peabody"
  name.middle => "quincy harold"
  name.suffix => "jr."
  name.to_s(:last_comma_first) => "peabody,george"
  name.to_s(:full) => "george quincy peabody jr."

  name2 = PersonName.new("peabody jr., george quincy harold", :last_first_middle)
  name.eql?(name2) => true

  addr = StreetAddress.new("204-b ne. 1st ave suite 4")
  addr.number => "204-b"
  addr.pre_direction => :northeast
  addr.name => "1st"
  addr.suffix => :avenue
  addr.unit_type => :suite
  addr.unit => "4"
  addr.to_s => "204-b northeast 1st avenue suite 4"

  ANSICounties.code_for('GA', 'FULTON') => 13121
  ANSICounties.code_for(:state => 'ga', :county => 'fulton') => 13121
  ANSICounties.data_for(13121) => { :state => 'GA', :county => 'FULTON' }
  
  phone = PhoneNumber.new '14045551212'
  phone.country_code => 1
  phone.area_code => '404'
  phone.number => '5551212'
  phone.exchange => '555'
  phone.suffix => '1212'
  phone.to_s => '1 (404) 555-1212'

  zip = ZipCode.new '30306-3522'
  zip.base => '30306'
  zip.plus_four => '3522'
  zip.to_s => '30306-3522'
  
  state = State.new 'california'
  state.sym => :ca
  state.to_s => 'California'
  state.to_s(:abbr) => 'CA'
  
  location = Location.new 'san francisco, ca 94114-1222'
  location.city => 'san francisco'
  location.state.to_s => 'California'
  location.zip.base => '94114'

Data source

The data that makes up lib/people_places_things/data/data.yml was generated from lib/people_places_things/data/raw.txt, which was downloaded from the US Census website.

License

SUID is released under the MIT License

people_places_things's People

Contributors

aroop avatar dburkes avatar dcleven avatar patricktulskie avatar

Watchers

 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.