Wikibase::Datatype::Snak - Wikibase snak datatype.
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;
This datatype is snak class for representing relation between property and value.
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'.
my $datatype = $obj->datatype;
Get data type.
Returns string.
my $datavalue = $obj->datavalue;
Get data value.
Returns instance of Wikibase::Datatype::Value.
my $property = $obj->property;
Get property name.
my $snaktype = $obj->snaktype;
Get snak type.
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.
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
Error::Pure, List::MoreUtils, Mo, Mo::utils, Readonly, Wikibase::Datatype::Utils.
Wikibase datatypes.
https://github.com/michal-josef-spacek/Wikibase-Datatype
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2020-2023 Michal Josef Špaček
BSD 2-Clause License
0.24
To install Wikibase::Datatype, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wikibase::Datatype
CPAN shell
perl -MCPAN -e shell install Wikibase::Datatype
For more information on module installation, please visit the detailed CPAN module installation guide.