Class: Daywalker::District
- Includes:
- HappyMapper
- Defined in:
- lib/daywalker/district.rb
Overview
Represents a Congressional district.
They have the following attributes:
-
number
-
state (as a two-letter abbreviation)
Class Method Summary collapse
-
.find_by_latlng(lat, lng) ⇒ Object
Find districts by latitude and longitude.
-
.find_by_zip(zip) ⇒ Object
Find districts by zip code.
Class Method Details
.find_by_latlng(lat, lng) ⇒ Object
Find districts by latitude and longitude.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/daywalker/district.rb', line 15 def self.find_by_latlng(lat, lng) # TODO use ArgumentError raise(ArgumentError, 'missing required parameter latitude') if lat.nil? query = { :latitude => lat, :longitude => lng, :apikey => Daywalker.api_key } response = get('/districts.getDistrictFromLatLong.xml', :query => query) handle_response(response) # TODO should only ever return one? end |
.find_by_zip(zip) ⇒ Object
Find districts by zip code
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/daywalker/district.rb', line 29 def self.find_by_zip(zip) # TODO use ArgumentError raise(ArgumentError, 'missing required parameter zip') if zip.nil? query = { :zip => zip, :apikey => Daywalker.api_key } response = get('/districts.getDistrictsFromZip.xml', :query => query) handle_response(response) end |