Class: ZipCode

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/zip_code.rb

Constant Summary

@@csv_cols =

Parsing, importing - borrows heavily from seymour


[ :zip_code, :city, :state, :county, :area_code, :city_type, 
:city_alias_abbreviation, :city_alias_name, :latitude, :longitude, 
:time_zone, :elevation, :county_fips, :day_light_savings ]

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) find_location_and_institution(zip_code)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/zip_code.rb', line 10

def self.find_location_and_institution(zip_code)
  if(zip_code and zip_code != "")
    state_abb = to_state(zip_code.to_i)
    location = Location.find_by_abbreviation(state_abb)
    location_name = location.name
    institutions = location.institutions 
  end
  if !institutions || institutions.empty?
    state_abb = to_state(zip_code)
    location = Location.find_by_abbreviation(state_abb)
    institutions = Institution.find(:all)
    location_name = location.name
  end
  return location_name, institutions
end

Instance Method Details

- (Object) county



26
27
28
# File 'app/models/zip_code.rb', line 26

def county
  return County.find_by_countycode_and_location_id(self.county_fips, self.location.id)
end

- (Object) location



29
30
31
# File 'app/models/zip_code.rb', line 29

def location
  return Location.find_by_abbreviation(self.state)
end