| 1 | package Wikibase::Datatype::Value::Quantity; | ||||||||||
| 2 | |||||||||||
| 3 | 23 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 23 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 23 | ▶ | use Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 23 | ▶ | use Mo qw(build is); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 23 | ▶ | use Mo::utils qw(check_number); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 23 | ▶ | use Wikibase::Datatype::Utils qw(check_entity); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 23 | our $VERSION = 0.40; | |||||||||
| 12 | |||||||||||
| 13 | 23 | extends 'Wikibase::Datatype::Value'; | |||||||||
| 14 | |||||||||||
| 15 | 23 | has lower_bound => ( | |||||||||
| 16 | is => 'ro', | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 23 | has unit => ( | |||||||||
| 20 | is => 'ro', | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 23 | has upper_bound => ( | |||||||||
| 24 | is => 'ro', | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 1 | ▶ | sub type { | ||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 28 | 1 | return 'quantity'; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 21 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||
| 32 | 21 | my $self = shift; | |||||||||
| 33 | |||||||||||
| 34 | 21 | ▶ | if (defined $self->{'unit'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 3 | check_entity($self, 'unit'); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 20 | check_number($self, 'value'); | |||||||||
| 39 | |||||||||||
| 40 | 20 | ▶ | if (defined $self->{'lower_bound'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 5 | check_number($self, 'lower_bound'); | |||||||||
| 42 | 5 | ▶ | if ($self->{'lower_bound'} > $self->{'value'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 1 | err "Parameter 'lower_bound' must be less than or equal to value."; | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | 19 | ▶ | if (defined $self->{'upper_bound'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 5 | check_number($self, 'upper_bound'); | |||||||||
| 48 | 5 | ▶ | if ($self->{'upper_bound'} < $self->{'value'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | err "Parameter 'upper_bound' must be greater than or equal to value."; | |||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 18 | return; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 23 | 1; | |||||||||
| 57 | |||||||||||
| 58 | __END__ | ||||||||||