NAME
Wikibase::Datatype::Print::Reference - Wikibase reference pretty print helpers.
SYNOPSIS
use Wikibase::Datatype::Print::Reference qw(print);
my $pretty_print_string = print($obj, $opts_hr);
my @pretty_print_lines = print($obj, $opts_hr);
SUBROUTINES
print
my $pretty_print_string = print($obj, $opts_hr);
my @pretty_print_lines = print($obj, $opts_hr);
Construct pretty print output for Wikibase::Datatype::Reference object.
Returns string in scalar context. Returns list of lines in array context.
ERRORS
print():
From Wikibase::Datatype::Print::Utils::defaults():
Defined text keys are bad.
Object isn't 'Wikibase::Datatype::Reference'.
EXAMPLE1
use strict;
use warnings;
use Wikibase::Datatype::Print::Reference;
use Wikibase::Datatype::Reference;
use Wikibase::Datatype::Snak;
use Wikibase::Datatype::Value::String;
use Wikibase::Datatype::Value::Time;
# Object.
my $obj = Wikibase::Datatype::Reference->new(
'snaks' => [
Wikibase::Datatype::Snak->new(
'datatype' => 'url',
'datavalue' => Wikibase::Datatype::Value::String->new(
'value' => 'https://skim.cz',
),
'property' => 'P854',
),
Wikibase::Datatype::Snak->new(
'datatype' => 'time',
'datavalue' => Wikibase::Datatype::Value::Time->new(
'value' => '+2013-12-07T00:00:00Z',
),
'property' => 'P813',
),
],
);
# Print.
print Wikibase::Datatype::Print::Reference::print($obj)."\n";
# Output:
# {
# P854: https://skim.cz
# P813: 7 December 2013 (Q1985727)
# }
EXAMPLE2
use strict;
use warnings;
use Wikibase::Cache;
use Wikibase::Cache::Backend::Basic;
use Wikibase::Datatype::Print::Reference;
use Wikibase::Datatype::Reference;
use Wikibase::Datatype::Snak;
use Wikibase::Datatype::Value::String;
use Wikibase::Datatype::Value::Time;
# Object.
my $obj = Wikibase::Datatype::Reference->new(
'snaks' => [
Wikibase::Datatype::Snak->new(
'datatype' => 'url',
'datavalue' => Wikibase::Datatype::Value::String->new(
'value' => 'https://skim.cz',
),
'property' => 'P854',
),
Wikibase::Datatype::Snak->new(
'datatype' => 'time',
'datavalue' => Wikibase::Datatype::Value::Time->new(
'value' => '+2013-12-07T00:00:00Z',
),
'property' => 'P813',
),
],
);
# Cache.
my $cache = Wikibase::Cache->new(
'backend' => 'Basic',
);
# Print.
print Wikibase::Datatype::Print::Reference::print($obj, {
'cache' => $cache,
})."\n";
# Output:
# {
# P854 (reference URL): https://skim.cz
# P813 (retrieved): 7 December 2013 (Q1985727)
# }
DEPENDENCIES
Error::Pure, Exporter, Readonly, Wikibase::Datatype::Print::Snak.
SEE ALSO
- Wikibase::Datatype::Reference
-
Wikibase reference datatype.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype-Print
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2020-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.17