| 1 | package Wikibase::Datatype::Print::Form; | ||||||||||
| 2 | |||||||||||
| 3 | 10 | ▶ | use base qw(Exporter); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 10 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 10 | ▶ | use Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 10 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 10 | ▶ | use Wikibase::Datatype::Print::Statement; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 10 | ▶ | use Wikibase::Datatype::Print::Utils qw(defaults print_statements); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 10 | ▶ | use Wikibase::Datatype::Print::Value::Item; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 10 | ▶ | use Wikibase::Datatype::Print::Value::Monolingual; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 10 | Readonly::Array our @EXPORT_OK => qw(print); | |||||||||
| 15 | |||||||||||
| 16 | 10 | our $VERSION = 0.21; | |||||||||
| 17 | |||||||||||
| 18 | 7 | ▶ | sub print { | ||||||||
|
Subroutine
print: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 19 | 7 | my ($obj, $opts_hr) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 7 | $opts_hr = defaults($obj, $opts_hr); | |||||||||
| 22 | |||||||||||
| 23 | 7 | ▶ | if (! $obj->isa('Wikibase::Datatype::Form')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 1 | err "Object isn't 'Wikibase::Datatype::Form'."; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | my @ret = ( | ||||||||||
| 28 | 6 | $opts_hr->{'texts'}->{'id'}.': '.$obj->id, | |||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | # Representation. | ||||||||||
| 32 | # XXX In every time one? | ||||||||||
| 33 | 6 | my ($representation) = @{$obj->representations}; | |||||||||
| 34 | 6 | ▶ | if (defined $representation) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 6 | push @ret, $opts_hr->{'texts'}->{'representation'}.': '. | |||||||||
| 36 | Wikibase::Datatype::Print::Value::Monolingual::print($representation, $opts_hr); | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | # Grammatical features | ||||||||||
| 40 | 6 | my @gr_features; | |||||||||
| 41 | 6 | foreach my $gr_feature (@{$obj->grammatical_features}) { | |||||||||
| 42 | 12 | push @gr_features, | |||||||||
| 43 | Wikibase::Datatype::Print::Value::Item::print($gr_feature, $opts_hr); | ||||||||||
| 44 | } | ||||||||||
| 45 | 6 | ▶ | if (@gr_features) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 6 | push @ret, $opts_hr->{'texts'}->{'grammatical_features'}.': '.(join ', ', @gr_features); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | # Statements. | ||||||||||
| 50 | 6 | push @ret, print_statements($obj, $opts_hr, | |||||||||
| 51 | \&Wikibase::Datatype::Print::Statement::print); | ||||||||||
| 52 | |||||||||||
| 53 | 6 | ▶ | return wantarray ? @ret : (join "\n", @ret); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 10 | 1; | |||||||||
| 57 | |||||||||||
| 58 | __END__ | ||||||||||