geocoding - ruby: given an ip address, find out the City and State -


i've been searching ten minutes, haven't found simple code sample yet.

basically, i'm looking this:

puts geocoder.lookup_location_by_ip("76.95.251.102")  result california, usa 

so ruby method decodes ip address in city, state.

these steps:

  1. install geocoder using:

    gem install geocoder 
  2. in ruby script use:

    require "geocoder" puts geocoder.address('76.95.251.102')   #change ip address accordingly. 
  3. run script city, state, zipcode, country.

    # => bellflower, ca 90706, united states 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -