Sha256: 99666c31fd234aa57a5174a4811f579a7ce804db5876d6876c303a77617e2f5e

Contents?: true

Size: 965 Bytes

Versions: 28

Compression:

Stored size: 965 Bytes

Contents

class ZipCode < ActiveRecord::Base
  set_primary_key :name
  
  belongs_to :egrid_subregion, :foreign_key => 'egrid_subregion_abbreviation'
  belongs_to :climate_division, :foreign_key => 'climate_division_name'
  belongs_to :state, :foreign_key => 'state_postal_abbreviation'
#  has_one :census_division, :through => :state
#  has_one :census_region, :through => :state
  has_many :residences

  
  acts_as_mappable :default_units => :miles,  # FIXME imperial
                   :lat_column_name => :latitude,
                   :lng_column_name => :longitude

  def set_latitude_and_longitude
    return if latitude.present? and longitude.present?
    a = Geokit::Geocoders::YahooGeocoder.geocode name
    update_attributes! :latitude => a.lat, :longitude => a.lng
  end
  
  data_miner do
    tap "Brighter Planet's sanitized zip codes", Earth.taps_server
    
    process "pull dependencies" do
      run_data_miner_on_belongs_to_associations
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
earth-0.1.2 lib/earth/locality/zip_code.rb
earth-0.1.1 lib/earth/locality/zip_code.rb
earth-0.1.0 lib/earth/locality/zip_code.rb
earth-0.0.43 lib/earth/locality/zip_code.rb
earth-0.0.42 lib/earth/locality/zip_code.rb
earth-0.0.41 lib/earth/locality/zip_code.rb
earth-0.0.40 lib/earth/locality/zip_code.rb
earth-0.0.39 lib/earth/locality/zip_code.rb
earth-0.0.38 lib/earth/locality/zip_code.rb
earth-0.0.37 lib/earth/locality/zip_code.rb
earth-0.0.36 lib/earth/locality/zip_code.rb
earth-0.0.35 lib/earth/locality/zip_code.rb
earth-0.0.34 lib/earth/locality/zip_code.rb
earth-0.0.33 lib/earth/locality/zip_code.rb
earth-0.0.32 lib/earth/locality/zip_code.rb
earth-0.0.31 lib/earth/locality/zip_code.rb
earth-0.0.30 lib/earth/locality/zip_code.rb
earth-0.0.29 lib/earth/locality/zip_code.rb
earth-0.0.28 lib/earth/locality/zip_code.rb
earth-0.0.27 lib/earth/locality/zip_code.rb