Class: MaxMind::GeoIP2::Model::City

Inherits:
Country
  • Object
show all
Defined in:
lib/maxmind/geoip2/model/city.rb

Overview

Model class for the data returned by the GeoIP2 City Plus web service and the City database. It is also used for GeoLite2 City lookups.

See dev.maxmind.com/geoip/docs/web-services?lang=en for more details.

See Country for inherited methods.

Direct Known Subclasses

Enterprise, Insights

Instance Attribute Summary collapse

Attributes inherited from Country

#continent, #country, #maxmind, #registered_country, #represented_country, #traits

Instance Method Summary collapse

Instance Attribute Details

#cityMaxMind::GeoIP2::Record::City (readonly)

City data for the IP address.



23
24
25
# File 'lib/maxmind/geoip2/model/city.rb', line 23

def city
  @city
end

#locationMaxMind::GeoIP2::Record::Location (readonly)

Location data for the IP address.



28
29
30
# File 'lib/maxmind/geoip2/model/city.rb', line 28

def location
  @location
end

#postalMaxMind::GeoIP2::Record::Postal (readonly)

Postal data for the IP address.



33
34
35
# File 'lib/maxmind/geoip2/model/city.rb', line 33

def postal
  @postal
end

#subdivisionsArray<MaxMind::GeoIP2::Record::Subdivision> (readonly)

The country subdivisions for the IP address.

The number and type of subdivisions varies by country, but a subdivision is typically a state, province, country, etc. Subdivisions are ordered from most general (largest) to most specific (smallest).

If the response did not contain any subdivisions, this attribute will be an empty array.



45
46
47
# File 'lib/maxmind/geoip2/model/city.rb', line 45

def subdivisions
  @subdivisions
end

Instance Method Details

#most_specific_subdivisionMaxMind::GeoIP2::Record::Subdivision?

The most specific subdivision returned.

If the response did not contain any subdivisions, this method returns nil.



62
63
64
# File 'lib/maxmind/geoip2/model/city.rb', line 62

def most_specific_subdivision
  @subdivisions.last
end