NAME
Toolforge::MixNMatch::Object::Catalog - Mix'n'match catalog datatype.
SYNOPSIS
use Toolforge::MixNMatch::Object::Catalog;
my $obj = Toolforge::MixNMatch::Object::Catalog->new(%params);
my $count = $obj->count;
my $type = $obj->type;
my $year_months = $obj->year_months;
my $users = $obj->users;
DESCRIPTION
This datatype is base class for Mix'n'match catalog.
METHODS
new
my $obj = Toolforge::MixNMatch::Object::Catalog->new(%params);
Constructor.
Returns instance of object.
countCount number of records in catalog. Parameter is required.
typeCatalog type in sense of Wikidata instance. Example is 'Q5' for human. Parameter is required.
year_monthsYear/months statistics. Reference to array with Toolforge::MixNMatch::Object::YearMonth instances. Default value is [].
usersUsers statistics. Reference to array with Toolforge::MixNMatch::Object::User instances. Default value is [].
count
my $count = $obj->count;
Get count.
Returns number.
type
my $type = $obj->type;
Get type.
Returns string.
year_months
my $year_months = $obj->year_months;
Get year/months statistics.
Returns reference to array with Toolforge::MixNMatch::Object::YearMonth instances.
users
my $users = $obj->users;
Get users statistics.
Returns reference to array with Toolforge::MixNMatch::Object::User instances.
ERRORS
new():
From Mo::utils::check_required():
Parameter 'count' is required.
Parameter 'type' is required.
From Mo::utils::Array::check_array_object():
Parameter 'users' must be a array.
Value: %s
Reference: %s
Parameter 'users' with array must contain 'Toolforge::MixNMatch::Object::Catalog::User' objects.
Value: %s
Reference: %s
Parameter 'year_months' must be a array.
Value: %s
Reference: %s
Parameter 'year_months' with array must contain 'Toolforge::MixNMatch::Object::Catalog::YearMonth' objects.
Value: %s
Reference: %s
EXAMPLE
use strict;
use warnings;
use Toolforge::MixNMatch::Object::Catalog;
use Toolforge::MixNMatch::Object::User;
use Toolforge::MixNMatch::Object::YearMonth;
# Object.
my $obj = Toolforge::MixNMatch::Object::Catalog->new(
'count' => 10,
'type' => 'Q5',
'users' => [
Toolforge::MixNMatch::Object::User->new(
'count' => 6,
'uid' => 1,
'username' => 'Skim',
),
Toolforge::MixNMatch::Object::User->new(
'count' => 4,
'uid' => 2,
'username' => 'Foo',
),
],
'year_months' => [
Toolforge::MixNMatch::Object::YearMonth->new(
'count' => 2,
'month' => 9,
'year' => 2020,
),
Toolforge::MixNMatch::Object::YearMonth->new(
'count' => 8,
'month' => 10,
'year' => 2020,
),
],
);
# Get count.
my $count = $obj->count;
# Get type.
my $type = $obj->type;
# Get year months stats.
my $year_months_ar = $obj->year_months;
# Get users.
my $users_ar = $obj->users;
# Print out.
print "Count: $count\n";
print "Type: $type\n";
print "Number of month/year statistics: ".(scalar @{$year_months_ar})."\n";
print "Number of users: ".(scalar @{$users_ar})."\n";
# Output:
# Count: 10
# Type: Q5
# Number of month/year statistics: 2
# Number of users: 2
DEPENDENCIES
Mo, Mo::utils, Mo::utils::Array.
SEE ALSO
- Toolforge::MixNMatch::Object
-
Toolforge Mix'n'match tool objects.
REPOSITORY
https://github.com/michal-josef-spacek/Toolforge-MixNMatch-Object
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© Michal Josef Špaček 2020-2025
BSD 2-Clause License
VERSION
0.04