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 web service and database. It is also used for GeoLite2 City lookups.

The only difference between the City and Insights model classes is which fields in each record may be populated. 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.



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

def city
  @city
end

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

Location data for the IP address.



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

def location
  @location
end

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

Postal data for the IP address.



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

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.



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

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.



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

def most_specific_subdivision
  @subdivisions.last
end