lib/geokit/geo_loc.rb in geokit-1.13.1 vs lib/geokit/geo_loc.rb in geokit-1.14.0
- old
+ new
@@ -23,11 +23,11 @@
# Location attributes. Full address is a concatenation of all values.
# For example:
# 100 Spear St, San Francisco, CA, 94101, US
# Street number and street name are extracted from the street address
# attribute if they don't exist
- attr_accessor :state_name, :state_code, :zip, :country_code, :country
+ attr_accessor :county, :state_name, :state_code, :zip, :country_code, :country
attr_accessor :all, :district, :sub_premise,
:neighborhood
attr_writer :state, :full_address, :street_number, :street_name, :formatted_address
attr_reader :city, :street_address
# Attributes set upon return from geocoding. Success will be true for
@@ -56,10 +56,11 @@
@street_address = h[:street_address]
@sub_premise = nil
@street_number = nil
@street_name = nil
@city = h[:city]
+ @county = h[:county]
@state = h[:state]
@state_code = h[:state_code]
@state_name = h[:state_name]
@zip = h[:zip]
@country_code = h[:country_code]
@@ -107,13 +108,13 @@
end
# gives you all the important fields as key-value pairs
def hash
res = {}
- fields = [:success, :lat, :lng, :country_code, :city, :state, :zip,
- :street_address, :district, :provider, :full_address, :is_us?,
- :ll, :precision, :district_fips, :state_fips, :block_fips, :sub_premise]
+ fields = %i[success lat lng country_code city county state zip
+ street_address district provider full_address is_us?
+ ll precision district_fips state_fips block_fips sub_premise]
fields.each { |s| res[s] = send(s.to_s) }
res
end
alias_method :to_hash, :hash
@@ -131,12 +132,12 @@
address
end
end
# Returns a comma-delimited string consisting of the street address, city,
- # state, zip, and country code. Only includes those attributes that are
- # non-blank.
+ # state, zip, and country code. Only includes those attributes
+ # that are non-blank.
def to_geocodeable_s
a = [street_address, district, city, state, zip, country_code].compact
a.delete_if { |e| !e || e == '' }
a.join(', ')
end
@@ -154,9 +155,10 @@
# Returns a string representation of the instance.
def to_s
["Provider: #{provider}",
"Street: #{street_address}",
"City: #{city}",
+ "County: #{county}",
"State: #{state}",
"Zip: #{zip}",
"Latitude: #{lat}",
"Longitude: #{lng}",
"Country: #{country_code}",