File Coverage

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


line stmt bran cond sub pod time code
1             package Wikibase::Datatype::Print::Value::Monolingual;
2              
3 48     48   904465 use base qw(Exporter);
  48         149  
  48         4433  
4 48     48   326 use strict;
  48         108  
  48         1080  
5 48     48   293 use warnings;
  48         137  
  48         1468  
6              
7 48     48   1211 use Error::Pure qw(err);
  48         22872  
  48         1980  
8 48     48   409 use Readonly;
  48         143  
  48         7802  
9              
10             Readonly::Array our @EXPORT_OK => qw(print);
11              
12             our $VERSION = 0.12;
13              
14             sub print {
15 46     46 1 3360 my ($obj, $opts_hr) = @_;
16              
17 46 100       244 if (! $obj->isa('Wikibase::Datatype::Value::Monolingual')) {
18 1         5 err "Object isn't 'Wikibase::Datatype::Value::Monolingual'.";
19             }
20              
21 45         210 return $obj->value.' ('.$obj->language.')';
22             }
23              
24             1;
25              
26             __END__
27              
28             =pod
29              
30             =encoding utf8
31              
32             =head1 NAME
33              
34             Wikibase::Datatype::Print::Value::Monolingual - Wikibase monolingual value pretty print helpers.
35              
36             =head1 SYNOPSIS
37              
38             use Wikibase::Datatype::Print::Value::Monolingual qw(print);
39              
40             my $pretty_print_string = print($obj, $opts_hr);
41              
42             =head1 SUBROUTINES
43              
44             =head2 C<print>
45              
46             my $pretty_print_string = print($obj, $opts_hr);
47              
48             Construct pretty print output for L<Wikibase::Datatype::Value::Monolingual>
49             object.
50              
51             Returns string.
52              
53             =head1 ERRORS
54              
55             print():
56             Object isn't 'Wikibase::Datatype::Value::Monolingual'.
57              
58             =head1 EXAMPLE
59              
60             =for comment filename=create_and_print_value_monolingual.pl
61              
62             use strict;
63             use warnings;
64              
65             use Wikibase::Datatype::Print::Value::Monolingual;
66             use Wikibase::Datatype::Value::Monolingual;
67              
68             # Object.
69             my $obj = Wikibase::Datatype::Value::Monolingual->new(
70             'language' => 'en',
71             'value' => 'English text',
72             );
73              
74             # Print.
75             print Wikibase::Datatype::Print::Value::Monolingual::print($obj)."\n";
76              
77             # Output:
78             # English text (en)
79              
80             =head1 DEPENDENCIES
81              
82             L<Error::Pure>,
83             L<Exporter>,
84             L<Readonly>.
85              
86             =head1 SEE ALSO
87              
88             =over
89              
90             =item L<Wikibase::Datatype::Value::Monolingual>
91              
92             Wikibase monolingual value datatype.
93              
94             =back
95              
96             =head1 REPOSITORY
97              
98             L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Print>
99              
100             =head1 AUTHOR
101              
102             Michal Josef Špaček L<mailto:skim@cpan.org>
103              
104             L<http://skim.cz>
105              
106             =head1 LICENSE AND COPYRIGHT
107              
108             © 2020-2023 Michal Josef Špaček
109              
110             BSD 2-Clause License
111              
112             =head1 VERSION
113              
114             0.12
115              
116             =cut