NAME

Wikibase::Datatype::Print::Property - Wikibase property pretty print helpers.

SYNOPSIS

use Wikibase::Datatype::Print::Property 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::Property 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::Property'.

EXAMPLE

use strict;
use warnings;

use Unicode::UTF8 qw(decode_utf8 encode_utf8);
use Wikibase::Datatype::Print::Property;
use Wikibase::Datatype::Property;
use Wikibase::Datatype::Reference;
use Wikibase::Datatype::Sitelink;
use Wikibase::Datatype::Snak;
use Wikibase::Datatype::Statement;
use Wikibase::Datatype::Value::Item;
use Wikibase::Datatype::Value::Monolingual;
use Wikibase::Datatype::Value::String;
use Wikibase::Datatype::Value::Time;

# Statement.
my $statement1 = Wikibase::Datatype::Statement->new(
        # instance of (P31) Wikidata property (Q18616576)
        'snak' => Wikibase::Datatype::Snak->new(
                'datatype' => 'wikibase-item',
                'datavalue' => Wikibase::Datatype::Value::Item->new(
                        'value' => 'Q18616576',
                ),
                'property' => 'P31',
        ),
);

# Main item.
my $obj = Wikibase::Datatype::Property->new(
        'aliases' => [
                Wikibase::Datatype::Value::Monolingual->new(
                        'language' => 'cs',
                        'value' => 'je',
                ),
                Wikibase::Datatype::Value::Monolingual->new(
                        'language' => 'en',
                        'value' => 'is a',
                ),
                Wikibase::Datatype::Value::Monolingual->new(
                        'language' => 'en',
                        'value' => 'is an',
                ),
        ],
        'datatype' => 'wikibase-item',
        'descriptions' => [
                Wikibase::Datatype::Value::Monolingual->new(
                        'language' => 'cs',
                        'value' => decode_utf8('tato položka je jedna konkrétní věc (exemplář, '.
                                'příklad) patřící do této třídy, kategorie nebo skupiny předmětů'),
                ),
                Wikibase::Datatype::Value::Monolingual->new(
                        'language' => 'en',
                        'value' => 'that class of which this subject is a particular example and member',
                ),
        ],
        'id' => 'P31',
        'labels' => [
                Wikibase::Datatype::Value::Monolingual->new(
                        'language' => 'cs',
                        'value' => decode_utf8('instance (čeho)'),
                ),
                Wikibase::Datatype::Value::Monolingual->new(
                        'language' => 'en',
                        'value' => 'instance of',
                ),
        ],
        'page_id' => 3918489,
        'statements' => [
                $statement1,
        ],
        'title' => 'Property:P31',
);

# Print.
print encode_utf8(scalar Wikibase::Datatype::Print::Property::print($obj))."\n";

# Output:
# Data type: wikibase-item
# Label: instance of (en)
# Description: that class of which this subject is a particular example and member (en)
# Aliases:
#   is a (en)
#   is an (en)
# Statements:
#   P31: Q18616576 (normal)

DEPENDENCIES

Exporter, Error::Pure, Readonly, Wikibase::Datatype::Print::Statement, Wikibase::Datatype::Print::Utils, Wikibase::Datatype::Print::Value::Monolingual.

SEE ALSO

Wikibase::Datatype::Property

Wikibase property datatype.

REPOSITORY

https://github.com/michal-josef-spacek/Wikibase-Datatype-Print

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2020-2024 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.17