GeoIP2/Record/City.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 21 / 21 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« GeoIP2/Model/Insights.pm ↑ Summary GeoIP2/Record/Continent.pm »
1 package GeoIP2::Record::City;
2 6 $GeoIP2::Record::City::VERSION = '0.050000';
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use GeoIP2::Types qw( NonNegativeInt PositiveInt Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 with 'GeoIP2::Role::Record::HasNames';
11  
12 6 has confidence => (
13 is => 'ro',
14 isa => NonNegativeInt,
15 predicate => 'has_confidence',
16 );
17  
18 6 has geoname_id => (
19 is => 'ro',
20 isa => PositiveInt,
21 predicate => 'has_geoname_id',
22 );
23  
24 6 1;
25  
26 # ABSTRACT: Contains data for the city record associated with an IP address
27  
28 __END__
29  
30 =pod
31  
32 =head1 NAME
33  
34 GeoIP2::Record::City - Contains data for the city record associated with an IP address
35  
36 =head1 VERSION
37  
38 version 0.050000
39  
40 =head1 SYNOPSIS
41  
42 use 5.008;
43  
44 use GeoIP2::WebService::Client;
45  
46 my $client = GeoIP2::WebService::Client->new(
47 user_id => 42,
48 license_key => 'abcdef123456',
49 );
50  
51 my $insights = $client->insights( ip => '24.24.24.24' );
52  
53 my $city_rec = $insights->city();
54 say $city_rec->name();
55  
56 =head1 DESCRIPTION
57  
58 This class contains the city-level data associated with an IP address.
59  
60 This record is returned by all the end points except the Country end point.
61  
62 =head1 METHODS
63  
64 This class provides the following methods:
65  
66 =head2 $city_rec->confidence()
67  
68 This returns a value from 0-100 indicating MaxMind's confidence that the city
69 is correct.
70  
71 This attribute is only available from the Insights end point.
72  
73 =head2 $city_rec->geoname_id()
74  
75 This returns a C<geoname_id> for the city.
76  
77 This attribute is returned by all end points.
78  
79 =head2 $city_rec->name()
80  
81 This returns a name for the city. The locale chosen depends on the C<locales>
82 argument that was passed to the record's constructor. This will be passed
83 through from the L<GeoIP2::WebService::Client> object you used to fetch the
84 data that populated this record.
85  
86 If the record does not have a name in any of the locales you asked for, this
87 method returns C<undef>.
88  
89 This attribute is returned by all end points.
90  
91 =head2 $city_rec->names()
92  
93 This returns a hash reference where the keys are locale codes and the values
94 are names. See L<GeoIP2::WebService::Client> for a list of the possible
95 locale codes.
96  
97 This attribute is returned by all end points.
98  
99 =head1 AUTHORS
100  
101 =over 4
102  
103 =item *
104  
105 Dave Rolsky <drolsky@maxmind.com>
106  
107 =item *
108  
109 Greg Oschwald <goschwald@maxmind.com>
110  
111 =item *
112  
113 Olaf Alders <oalders@maxmind.com>
114  
115 =back
116  
117 =head1 COPYRIGHT AND LICENSE
118  
119 This software is copyright (c) 2014 by MaxMind, Inc..
120  
121 This is free software; you can redistribute it and/or modify it under
122 the same terms as the Perl 5 programming language system itself.
123  
124 =cut
« GeoIP2/Model/Insights.pm ↑ Summary GeoIP2/Record/Continent.pm »