-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for optional fields when geocoding
This will require a major version bump, as the API has changed: parsing options hashes out of the splatted arrays was proving way too hairy for reverse geocoding, so both `geocode` and `reverse_geocode` now expect to be handed an array at all times and an optional hash of options. Signed-off-by: David Celis <me@davidcel.is>
- Loading branch information
1 parent
c5f8de7
commit b49b3e6
Showing
18 changed files
with
697 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Geocodio | ||
class CongressionalDistrict | ||
attr_reader :name | ||
attr_reader :district_number | ||
attr_reader :congress_number | ||
|
||
def initialize(payload = {}) | ||
@name = payload['name'] | ||
@district_number = payload['district_number'].to_i | ||
@congress_number = payload['congress_number'].to_i | ||
@congress_years = payload['congress_years'] | ||
end | ||
|
||
def congress_years | ||
first, last = @congress_years.split('-').map(&:to_i) | ||
first..last | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Geocodio | ||
class SchoolDistrict | ||
attr_reader :name | ||
attr_reader :lea_code | ||
attr_reader :grade_low | ||
attr_reader :grade_high | ||
|
||
def initialize(payload = {}) | ||
@name = payload['name'] | ||
@lea_code = payload['lea_code'] | ||
@grade_low = payload['grade_low'] | ||
@grade_high = payload['grade_high'] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Geocodio | ||
class StateLegislativeDistrict | ||
attr_accessor :name | ||
attr_accessor :district_number | ||
|
||
def initialize(payload = {}) | ||
@name = payload['name'] | ||
@district_number = payload['district_number'].to_i | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Geocodio | ||
class Timezone | ||
attr_reader :name | ||
attr_reader :utc_offset | ||
|
||
def initialize(payload = {}) | ||
@name = payload['name'] | ||
@utc_offset = payload['utc_offset'] | ||
@observes_dst = payload['observes_dst'] | ||
end | ||
|
||
def observes_dst? | ||
!!@observes_dst | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.