NAME
Wikibase::Datatype::Value::Quantity - Wikibase quantity value datatype.
SYNOPSIS
use Wikibase::Datatype::Value::Quantity;
my $obj = Wikibase::Datatype::Value::Quantity->new(%params);
my $lower_bound = $obj->lower_bound;
my $type = $obj->type;
my $unit = $obj->unit;
my $upper_bound = $obj->upper_bound;
my $value = $obj->value;
DESCRIPTION
This datatype is quantity class for representation of quantity. Optionaly we can define unit of quantity.
METHODS
new
my $obj = Wikibase::Datatype::Value::Quantity->new(%params);
Constructor.
Returns instance of object.
lower_bound
Lower bound of value. Value must be a positive or negative number. Parameter is optional. Default value is 0.
unit
Unit of instance. Default value is 1 (without unit).
upper_bound
Upper bound of value. Value must be a positive or negative number. Parameter is optional. Default value is 0.
value
Value of instance. Value must be a positive or negative number. Parameter is required.
lower_bound
my $lower_bound = $obj->lower_bound;
Get lower bound.
Returns number.
type
my $type = $obj->type;
Get type. This is constant 'string'.
Returns string.
unit
my $unit = $obj->unit;
Get unit. Unit is entity (e.g. /^Q\d+$/).
Returns string.
upper_bound
my $upper_bound = $obj->upper_bound;
Get upper bound.
Returns number.
value
my $value = $obj->value;
Get value.
Returns string.
ERRORS
new():
From Mo::utils::check_number():
Parameter 'lower_bound' must be a number.
Parameter 'upper_bound' must be a number.
Parameter 'value' must be a number.
From Wikibase::Datatype::Utils::check_entity():
Parameter 'unit' must begin with 'Q' and number after it.
From Wikibase::Datatype::Value::new():
Parameter 'value' is required.
Parameter 'lower_bound' must be less than value.
Parameter 'upper_bound' must be greater than value.
EXAMPLE1
use strict;
use warnings;
use Wikibase::Datatype::Value::Quantity;
# Object.
my $obj = Wikibase::Datatype::Value::Quantity->new(
'value' => '10',
);
# Get type.
my $type = $obj->type;
# Get unit.
my $unit = $obj->unit;
# Get value.
my $value = $obj->value;
# Print out.
print "Type: $type\n";
if (defined $unit) {
print "Unit: $unit\n";
}
print "Value: $value\n";
# Output:
# Type: quantity
# Value: 10
EXAMPLE2
use strict;
use warnings;
use Wikibase::Datatype::Value::Quantity;
# Object.
my $obj = Wikibase::Datatype::Value::Quantity->new(
'unit' => 'Q190900',
'value' => '10',
);
# Get type.
my $type = $obj->type;
# Get unit.
my $unit = $obj->unit;
# Get value.
my $value = $obj->value;
# Print out.
print "Type: $type\n";
print "Unit: $unit\n";
print "Value: $value\n";
# Output:
# Type: quantity
# Unit: Q190900
# Value: 10
DEPENDENCIES
Error::Pure, Mo, Mo::utils, Wikibase::Datatype::Utils, Wikibase::Datatype::Value.
SEE ALSO
- Wikibase::Datatype::Value
-
Wikibase datatypes.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2020-2023 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.33