NAME

Wikibase::Datatype::Snak - Wikibase snak datatype.

SYNOPSIS

use Wikibase::Datatype::Snak;

my $obj = Wikibase::Datatype::Snak->new(%params);
my $datatype = $obj->datatype;
my $datavalue = $obj->datavalue;
my $property = $obj->property;
my $snaktype = $obj->snaktype;

DESCRIPTION

This datatype is snak class for representing relation between property and value.

METHODS

new

my $obj = Wikibase::Datatype::Snak->new(%params);

Constructor.

Retruns instance of object.

  • datatype

    Type of data. Parameter is required.

  • datavalue

    Value of data. Parameter is required.

  • property

    Property name (like /^P\d+$/). Parameter is required.

  • snaktype

    Snak type. Parameter is string with these possible values: novalue somevalue value Parameter is optional. Default value is 'value'.

datatype

my $datatype = $obj->datatype;

Get data type.

Returns string.

datavalue

my $datavalue = $obj->datavalue;

Get data value.

Returns instance of Wikibase::Datatype::Value.

property

my $property = $obj->property;

Get property name.

Returns string.

snaktype

my $snaktype = $obj->snaktype;

Get snak type.

Returns string.

ERRORS

new():
        From Mo::utils::check_required():
                Parameter 'datatype' is required.
                Parameter 'datavalue' is required.
                Parameter 'property' is required.
        From Mo::utils::check_isa():
                Parameter 'datavalue' must be a 'Wikibase::Datatype::Value::%s' object.
        From Wikibase::Datatype::Utils::check_property():
                Parameter 'property' must begin with 'P' and number after it.
        Parameter 'datatype' = '%s' isn't supported.
        Parameter 'snaktype' = '%s' isn't supported.

EXAMPLE

use strict;
use warnings;

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',
);

# Get value.
my $datavalue = $obj->datavalue->value;

# Get datatype.
my $datatype = $obj->datatype;

# Get property.
my $property = $obj->property;

# Print out.
print "Property: $property\n";
print "Type: $datatype\n";
print "Value: $datavalue\n";

# Output:
# Property: P31
# Type: wikibase-item
# Value: Q5

DEPENDENCIES

Error::Pure, List::MoreUtils, Mo, Mo::utils, Readonly, Wikibase::Datatype::Utils.

SEE ALSO

Wikibase::Datatype

Wikibase datatypes.

REPOSITORY

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

AUTHOR

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

http://skim.cz

LICENSE AND COPYRIGHT

© Michal Josef Špaček 2020

BSD 2-Clause License

VERSION

0.01