Wikibase::Datatype::Sitelink - Wikibase sitelink datatype.
use Wikibase::Datatype::Sitelink; my $obj = Wikibase::Datatype::Sitelink->new(%params); my $badges_ar = $obj->badges; my $site = $obj->site; my $title = $obj->title;
This datatype is sitelink class for representing link to wikimedia projects (e.g. Czech Wikipedia).
new
my $obj = Wikibase::Datatype::Sitelink->new(%params);
Constructor.
Returns instance of object.
badges
Badges. Default value is [].
site
Site shortcut (e.g. cswiki). Parameter is required.
title
Page title (e.g. 'Main Page'). Parameter is required.
my $badges_ar = $obj->badges;
Get badges (Badge is link to item - regexp /^Q\d+$/).
Returns reference to array with strings.
my $site = $obj->site;
Get site.
Returns string.
my $title = $obj->title;
Get title.
new(): From Mo::utils::check_required(): Parameter 'site' is required. Parameter 'title' is required. From Mo::utils::check_array_object(): Badge isn't 'Wikibase::Datatype::Value::Item' object. Parameter 'badges' must be a array.
use strict; use warnings; use Unicode::UTF8 qw(decode_utf8 encode_utf8); use Wikibase::Datatype::Sitelink; use Wikibase::Datatype::Value::Item; # Object. my $obj = Wikibase::Datatype::Sitelink->new( 'badges' => [ Wikibase::Datatype::Value::Item->new( 'value' => 'Q123', ), ], 'site' => 'cswiki', 'title' => decode_utf8('Hlavní strana'), ); # Get badges. my $badges_ar = [map { $_->value } @{$obj->badges}]; # Get site. my $site = $obj->site; # Get title. my $title = $obj->title; # Print out. print 'Badges: '.(join ', ', @{$badges_ar})."\n"; print "Site: $site\n"; print 'Title: '.encode_utf8($title)."\n"; # Output: # Badges: Q123 # Site: cswiki # Title: Hlavní strana
Mo, Mo::utils.
Wikibase datatypes.
https://github.com/michal-josef-spacek/Wikibase-Datatype
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© Michal Josef Špaček 2020-2022
BSD 2-Clause License
0.16
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.