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

Mo, Mo::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

© 2020-2025 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.37

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy