NAME

Geo::Location::IP::Model::Country - Records associated with a country

VERSION

version 0.002

SYNOPSIS

use Geo::Location::IP::Database::Reader;
my $reader = Geo::Location::IP::Database::Reader->new(
  file    => '/path/to/Country.mmdb',
  locales => ['de', 'en'],
);
eval {
  my $country_model = $reader->country(ip => '1.2.3.4');
  my $country       = $country_model->country;
  my $continent     = $country_model->continent;
  printf "%s in %s\n", $country->name, $continent->name;
};

DESCRIPTION

This class contains records from an IP address query in a country database.

SUBROUTINES/METHODS

new

my $country_model = Geo::Location::IP::Model::Country->new(
  raw => {
      continent           => {names    => {en => 'Europe'}},
      country             => {names    => {en => 'Germany'}},
      maxmind             => {queries_remaining => 9999},
      registered_country  => {names    => {en => 'Germany'}},
      represented_country => {
        names => {en => 'United States'},
        type  => 'military',
      },
      traits => {domain => 'example.com'},
  },
  ip_address => $ip_address,
  locales    => ['en'],
);

Creates a new object.

All records may contain undefined values.

continent

my $continent = $country_model->continent;

Returns a Geo::Location::IP::Record::Continent object.

country

my $country = $country_model->country;

Returns a Geo::Location::IP::Record::Country object.

maxmind

my $maxmind = $country_model->maxmind;

Returns a Geo::Location::IP::Record::MaxMind object.

registered_country

my $country = $country_model->registered_country;

Returns a Geo::Location::IP::Record::Country object for the country where the ISP registered the network.

represented_country

my $country = $country_model->represented_country;

Returns a Geo::Location::IP::Record::RepresentedCountry for the country represented by the users of the IP address. For example, the country represented by an overseas military base.

traits

my $traits = $country_model->traits;

Returns a Geo::Location::IP::Record::Traits object with various details about the queried IP address.

DIAGNOSTICS

None.

CONFIGURATION AND ENVIRONMENT

None.

DEPENDENCIES

None.

INCOMPATIBILITIES

None.

BUGS AND LIMITATIONS

None known.

AUTHOR

Andreas Vögele <voegelas@cpan.org>

LICENSE AND COPYRIGHT

Copyright (C) 2025 Andreas Vögele

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.