File Coverage

blib/lib/Wikibase/Datatype/Print/Value/Globecoordinate.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 29 29 100.0


line stmt bran cond sub pod time code
1             package Wikibase::Datatype::Print::Value::Globecoordinate;
2              
3 44     44   913330 use base qw(Exporter);
  44         190  
  44         4138  
4 44     44   357 use strict;
  44         108  
  44         881  
5 44     44   208 use warnings;
  44         105  
  44         1343  
6              
7 44     44   1156 use Error::Pure qw(err);
  44         23596  
  44         1868  
8 44     44   405 use Readonly;
  44         122  
  44         8053  
9              
10             Readonly::Array our @EXPORT_OK => qw(print);
11              
12             our $VERSION = 0.13;
13              
14             sub print {
15 3     3 1 1213 my ($obj, $opts_hr) = @_;
16              
17 3 100       31 if (! $obj->isa('Wikibase::Datatype::Value::Globecoordinate')) {
18 1         5 err "Object isn't 'Wikibase::Datatype::Value::Globecoordinate'.";
19             }
20              
21 2         12 my $ret = '('.$obj->latitude.', '.$obj->longitude.')';
22              
23 2         45 return $ret;
24             }
25              
26             1;
27              
28             __END__
29              
30             =pod
31              
32             =encoding utf8
33              
34             =head1 NAME
35              
36             Wikibase::Datatype::Print::Value::Globecoordinate - Wikibase globe coordinate value pretty print helpers.
37              
38             =head1 SYNOPSIS
39              
40             use Wikibase::Datatype::Print::Value::Globecoordinate qw(print);
41              
42             my $pretty_print_string = print($obj, $opts_hr);
43             my @pretty_print_lines = print($obj, $opts_hr);
44              
45             =head1 SUBROUTINES
46              
47             =head2 C<print>
48              
49             my $pretty_print_string = print($obj, $opts_hr);
50             my @pretty_print_lines = print($obj, $opts_hr);
51              
52             Construct pretty print output for L<Wikibase::Datatype::Value::Globecoordinate>
53             object.
54              
55             Returns string in scalar context.
56             Returns list of lines in array context.
57              
58             =head1 ERRORS
59              
60             print():
61             Object isn't 'Wikibase::Datatype::Value::Globecoordinate'.
62              
63             =head1 EXAMPLE
64              
65             =for comment filename=create_and_print_value_globecoordinate.pl
66              
67             use strict;
68             use warnings;
69              
70             use Wikibase::Datatype::Print::Value::Globecoordinate;
71             use Wikibase::Datatype::Value::Globecoordinate;
72              
73             # Object.
74             my $obj = Wikibase::Datatype::Value::Globecoordinate->new(
75             'value' => [49.6398383, 18.1484031],
76             );
77              
78             # Print.
79             print Wikibase::Datatype::Print::Value::Globecoordinate::print($obj)."\n";
80              
81             # Output:
82             # (49.6398383, 18.1484031)
83              
84             =head1 DEPENDENCIES
85              
86             L<Error::Pure>,
87             L<Exporter>,
88             L<Readonly>.
89              
90             =head1 SEE ALSO
91              
92             =over
93              
94             =item L<Wikibase::Datatype::Value::Globecoordinate>
95              
96             Wikibase globe coordinate value datatype.
97              
98             =back
99              
100             =head1 REPOSITORY
101              
102             L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Print>
103              
104             =head1 AUTHOR
105              
106             Michal Josef Špaček L<mailto:skim@cpan.org>
107              
108             L<http://skim.cz>
109              
110             =head1 LICENSE AND COPYRIGHT
111              
112             © 2020-2023 Michal Josef Špaček
113              
114             BSD 2-Clause License
115              
116             =head1 VERSION
117              
118             0.13
119              
120             =cut