Class: Zipcode

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/generators/us_zipcode/templates/zipcode_model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_city(city) ⇒ Object



14
15
16
# File 'lib/generators/us_zipcode/templates/zipcode_model.rb', line 14

def find_by_city(city)
  includes(:county).where("city like '#{city}%'")
end

Instance Method Details

#county_and_zipObject



19
20
21
# File 'lib/generators/us_zipcode/templates/zipcode_model.rb', line 19

def county_and_zip
  "#{county.name}: #{code}"
end

#is_geocoded?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/generators/us_zipcode/templates/zipcode_model.rb', line 27

def is_geocoded?
  (!lat.nil? && !lon.nil?)
end

#latlonObject



23
24
25
# File 'lib/generators/us_zipcode/templates/zipcode_model.rb', line 23

def latlon
  [lat, lon]
end