NAME
Wikibase::Datatype::Sitelink - Wikibase sitelink datatype.
SYNOPSIS
use Wikibase::Datatype::Sitelink;
my $obj = Wikibase::Datatype::Sitelink->new(%params);
my $badges_ar = $obj->badges;
my $site = $obj->site;
my $title = $obj->title;
DESCRIPTION
This datatype is sitelink class for representing link to wikimedia projects (e.g. Czech Wikipedia).
METHODS
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.
badges
my $badges_ar = $obj->badges;
Get badges (Badge is link to item - regexp /^Q\d+$/).
Returns reference to array with strings.
site
my $site = $obj->site;
Get site.
Returns string.
title
my $title = $obj->title;
Get title.
Returns string.
ERRORS
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.
EXAMPLE
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
DEPENDENCIES
SEE ALSO
- Wikibase::Datatype
-
Wikibase datatypes.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2020-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.34