File Coverage

blib/lib/GeoIP2/Record/Continent.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package GeoIP2::Record::Continent;
2              
3 12     12   75 use strict;
  12         19  
  12         307  
4 12     12   51 use warnings;
  12         21  
  12         408  
5              
6             our $VERSION = '2.006002';
7              
8 12     12   57 use Moo;
  12         17  
  12         58  
9              
10 12     12   3438 use GeoIP2::Types qw( PositiveInt Str );
  12         33  
  12         696  
11              
12 12     12   85 use namespace::clean -except => 'meta';
  12         22  
  12         126  
13              
14             with 'GeoIP2::Role::Record::HasNames';
15              
16             has code => (
17             is => 'ro',
18             isa => Str,
19             predicate => 'has_code',
20             );
21              
22             has geoname_id => (
23             is => 'ro',
24             isa => PositiveInt,
25             predicate => 'has_geoname_id',
26             );
27              
28             1;
29              
30             # ABSTRACT: Contains data for the continent record associated with an IP address
31              
32             __END__
33              
34             =pod
35              
36             =encoding UTF-8
37              
38             =head1 NAME
39              
40             GeoIP2::Record::Continent - Contains data for the continent record associated with an IP address
41              
42             =head1 VERSION
43              
44             version 2.006002
45              
46             =head1 SYNOPSIS
47              
48             use 5.008;
49              
50             use GeoIP2::WebService::Client;
51              
52             my $client = GeoIP2::WebService::Client->new(
53             account_id => 42,
54             license_key => 'abcdef123456',
55             );
56              
57             my $insights = $client->insights( ip => '24.24.24.24' );
58              
59             my $continent_rec = $insights->continent();
60             print $continent_rec->name(), "\n";
61              
62             =head1 DESCRIPTION
63              
64             This class contains the continent-level data associated with an IP address.
65              
66             This record is returned by all the end points.
67              
68             =head1 METHODS
69              
70             This class provides the following methods:
71              
72             =head2 $continent_rec->code()
73              
74             This returns a two character continent code like "NA" (North America) or "OC"
75             (Oceania).
76              
77             This attribute is returned by all end points.
78              
79             =head2 $continent_rec->geoname_id()
80              
81             This returns a C<geoname_id> for the continent.
82              
83             This attribute is returned by all end points.
84              
85             =head2 $continent_rec->name()
86              
87             This returns a name for the continent. The locale chosen depends on the
88             C<locales> argument that was passed to the record's constructor. This will be
89             passed through from the L<GeoIP2::WebService::Client> object you used to fetch
90             the data that populated this record.
91              
92             If the record does not have a name in any of the locales you asked for, this
93             method returns C<undef>.
94              
95             This attribute is returned by all end points.
96              
97             =head2 $continent_rec->names()
98              
99             This returns a hash reference where the keys are locale codes and the values
100             are names. See L<GeoIP2::WebService::Client> for a list of the possible
101             locale codes.
102              
103             This attribute is returned by all end points.
104              
105             =head1 SUPPORT
106              
107             Bugs may be submitted through L<https://github.com/maxmind/GeoIP2-perl/issues>.
108              
109             =head1 AUTHORS
110              
111             =over 4
112              
113             =item *
114              
115             Dave Rolsky <drolsky@maxmind.com>
116              
117             =item *
118              
119             Greg Oschwald <goschwald@maxmind.com>
120              
121             =item *
122              
123             Mark Fowler <mfowler@maxmind.com>
124              
125             =item *
126              
127             Olaf Alders <oalders@maxmind.com>
128              
129             =back
130              
131             =head1 COPYRIGHT AND LICENSE
132              
133             This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
134              
135             This is free software; you can redistribute it and/or modify it under
136             the same terms as the Perl 5 programming language system itself.
137              
138             =cut