The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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.

     Possible datatypes are (datavalue instance in parenthesis):
     - commonsMedia (Wikibase::Datatype::Value::String)
     - external-id (Wikibase::Datatype::Value::String)
     - geo-shape (Wikibase::Datatype::Value::String)
     - globe-coordinate (Wikibase::Datatype::Value::Globecoordinate)
     - math (Wikibase::Datatype::Value::String)
     - monolingualtext (Wikibase::Datatype::Value::Monolingual)
     - musical-notation (Wikibase::Datatype::Value::String)
     - quantity (Wikibase::Datatype::Value::Quantity)
     - string (Wikibase::Datatype::Value::String)
     - tabular-data (Wikibase::Datatype::Value::String)
     - time (Wikibase::Datatype::Value::Time)
     - url (Wikibase::Datatype::Value::String)
     - wikibase-item (Wikibase::Datatype::Value::Item)
     - wikibase-property (Wikibase::Datatype::Value::Property)
  • datavalue

    Value of data in form of Wikibase::Datatype::Value instance for concrete datatype. Parameter is required in situation when snaktype = 'value'.

  • 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;

 # Get snak type.
 my $snaktype = $obj->snaktype;

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

 # Output:
 # Property: P31
 # Type: wikibase-item
 # Value: Q5
 # Snak type: value

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-2022

BSD 2-Clause License

VERSION

0.13