line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package Business::UPS::Tracking::Element::Weight; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
1
|
|
|
1
|
|
4489
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
59
|
use 5.0100; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2942
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Business::UPS::Tracking::Utils; |
10
|
|
|
|
|
|
|
use Business::UPS::Tracking::Element::Code; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Business::UPS::Tracking::Element::Weight - A shipment or package weight |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class represents a declaration of weight. Usually it is created |
21
|
|
|
|
|
|
|
automatically from a L<Business::UPS::Tracking::Shipment> object. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This module uses overload for stringification if called in string context. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 ACCESSORS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 xml |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Original L<XML::LibXML::Node> node. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 UnitOfMeasurement |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Unit of measurement. |
34
|
|
|
|
|
|
|
Returns a L<Business::UPS::Tracking::Element::Code> object. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 Weight |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Weight value (e.g. '5.50') |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'xml' => ( |
43
|
|
|
|
|
|
|
is => 'rw', |
44
|
|
|
|
|
|
|
isa => 'XML::LibXML::Node', |
45
|
|
|
|
|
|
|
required => 1, |
46
|
|
|
|
|
|
|
trigger => \&_build_weight, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
has 'UnitOfMeasurement'=> ( |
49
|
|
|
|
|
|
|
is => 'rw', |
50
|
|
|
|
|
|
|
isa => 'Business::UPS::Tracking::Element::Code', |
51
|
|
|
|
|
|
|
lazy_build => 1, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
has 'Weight'=> ( |
54
|
|
|
|
|
|
|
is => 'rw', |
55
|
|
|
|
|
|
|
isa => 'Num', |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _build_weight { |
59
|
|
|
|
|
|
|
my ($self,$xml) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $unit = Business::UPS::Tracking::Element::Code->new( |
62
|
|
|
|
|
|
|
xml => $xml->findnodes('UnitOfMeasurement')->get_node(1) |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->UnitOfMeasurement($unit); |
66
|
|
|
|
|
|
|
$self->Weight($xml->findvalue('Weight')); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub serialize { |
72
|
|
|
|
|
|
|
my ($self) = @_; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return $self->printall; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 METHODS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 printall |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns the weight as a string (eg. '14.5 KGS') |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 meta |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Moose meta method |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub printall { |
90
|
|
|
|
|
|
|
my ($self) = @_; |
91
|
|
|
|
|
|
|
return $self->Weight.' '.$self->UnitOfMeasurement->Code; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
95
|
|
|
|
|
|
|
no Moose; |
96
|
|
|
|
|
|
|
1; |