NAME

Wikibase::Datatype::Print::Snak - Wikibase snak pretty print helpers.

SYNOPSIS

use Wikibase::Datatype::Print::Snak 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::Snak 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::Snak'.
        Bad snaktype.
                snaktype: %s

EXAMPLE1

use strict;
use warnings;

use Wikibase::Datatype::Print::Snak;
use Wikibase::Datatype::Snak;
use Wikibase::Datatype::Value::Item;

# Object.
my $obj = Wikibase::Datatype::Snak->new(
        'datatype' => 'wikibase-item',
        'datavalue' => Wikibase::Datatype::Value::Item->new(
                'value' => 'Q5',
        ),
        'property' => 'P31',
);

# Print.
print Wikibase::Datatype::Print::Snak::print($obj)."\n";

# Output:
# P31: Q5

EXAMPLE2

use strict;
use warnings;

use Wikibase::Cache;
use Wikibase::Cache::Backend::Basic;
use Wikibase::Datatype::Print::Snak;
use Wikibase::Datatype::Snak;
use Wikibase::Datatype::Value::Item;

# Object.
my $obj = Wikibase::Datatype::Snak->new(
        'datatype' => 'wikibase-item',
        'datavalue' => Wikibase::Datatype::Value::Item->new(
                'value' => 'Q5',
        ),
        'property' => 'P31',
);

# Cache.
my $cache = Wikibase::Cache->new(
        'backend' => 'Basic',
);

# Print.
print Wikibase::Datatype::Print::Snak::print($obj, {
        'cache' => $cache,
})."\n";

# Output:
# P31 (instance of): Q5

DEPENDENCIES

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

SEE ALSO

Wikibase::Datatype::Snak

Wikibase snak 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