Sha256: f33b9446ca75952f957db1f938078f666705f3b290157059c73254eb4610d5b3

Contents?: true

Size: 554 Bytes

Versions: 4

Compression:

Stored size: 554 Bytes

Contents

require_relative './zips'

module Geomancer
  module ZipCode
    def self.geolocate address
      address ||= ""
      zip = address.match(/^(?:.* )?(\d\d\d\d\d)(?:-\d\d\d\d)?$/)

      if zip.nil? || zip[1].nil?
        lat = nil
        long = nil
      else
        zip_code = ZIP_CODES[zip[1]]

        if zip_code.nil?
          lat = nil
          long = nil
        else
          lat = zip_code[:latitude]
          long = zip_code[:longitude]
        end
        
      end
      
      {:latitude => lat, :longitude => long}
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
geomancer-0.7.1 lib/geomancer/zip_code.rb
geomancer-0.7.0 lib/geomancer/zip_code.rb
geomancer-0.6.1 lib/geomancer/zip_code.rb
geomancer-0.6.0 lib/geomancer/zip_code.rb