Skip to content

Parsers and formatters for person names, street addresses, city/state/zip, phone numbers, etc.

License

Notifications You must be signed in to change notification settings

netconstructor/people_places_things

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Parsers and formatters for person names, street addresses, city/state/zip, phone numbers, etc.

Resources

License

Stars

Watchers

Forks

Packages

No packages published