1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
package Class::Measure::Length;
use 5.008001;
use strict;
use warnings;
our $VERSION = '0.10';
=encoding utf8
=head1 NAME
Class::Measure::Length - Calculate measurements of length.
=head1 SYNOPSIS
use Class::Measure::Length;
print length( 2, 'km' )->meters();
=cut
use base qw( Class::Measure );
use Sub::Exporter -setup => {
exports => [qw( length )]
};
=head1 METHODS
This module inherits all the methods made available by
L<Class::Measure>.
=head2 length
$m = length( 2, 'metres' );
Creates a new measurement object.
=cut
sub length { return __PACKAGE__->new(@_); }
=head1 UNITS
=head2 International System of Units
Also known as SI and "metric", this unit of measure
includes the following.
kilometre
metre
centimetre
millimetre
decimetre
micrometre
nanometre
And all veriations are aliased, such as "m", "meter",
"meters", "metres".
=cut
__PACKAGE__->reg_units(
qw( kilometre centimetre millimetre decimetre micrometre nanometre metre )
);
__PACKAGE__->reg_aliases(
['kilometer','km','kilometers','kilometres','klick','klicks'] => 'kilometre',
['meter','m','meters','metres'] => 'metre',
['centimeter','cm','centimeters','centimetres'] => 'centimetre',
['millimeter','mm','millimeters','millimetres'] => 'millimetre',
['decimeter','decimeters','decimetres'] => 'decimetre',
['micrometer','micrometers','micron','microns','micrometres'] => 'micrometre',
['nanometer','nanometers','nanometres'] => 'nanometre',
);
__PACKAGE__->reg_convs(
'km' => 1000, 'm',
100, 'cm' => 'm',
10, 'mm' => 'cm',
'decimetre' => 10, 'cm',
1000, 'microns' => 'mm',
1000, 'nanometers' => 'micron',
);
=head2 Shared
These units are shared by with the US and Imperial
unit systems.
inch
foot
yard
rod
mile
chain
furlong
All relevant aliases included.
=cut
__PACKAGE__->reg_units(
qw( inch foot yard rod mile chain furlong )
);
__PACKAGE__->reg_aliases(
['in','inches'] => 'inch',
['feet','ft'] => 'foot',
'yards' => 'yard',
['pole','poles','perch','perches','rods'] => 'rod',
'miles' => 'mile',
'chains' => 'chain',
'furlongs' => 'furlong',
);
__PACKAGE__->reg_convs(
'inch' => 25.4, 'mm',
'foot' => 12, 'inches',
'yard' => 3, 'feet',
'yard' => 91.44, 'cm',
'rod' => 16.5, 'feet',
'mile' => 1.609344, 'km',
'mile' => 5280, 'feet',
'chain' => 66, 'feet',
'furlong' => 10, 'chains',
);
=head2 United Stats
Units specific to the United States.
survey_mile
link
fathom
cable_length
Aliases included.
=cut
__PACKAGE__->reg_units(
qw( survey_mile link fathom cable_length )
);
__PACKAGE__->reg_aliases(
'survey_miles' => 'survey_mile',
'links' => 'link',
'fathoms' => 'fathom',
'cable_lengths' => 'cable_length',
);
__PACKAGE__->reg_convs(
'survey_mile' => 8, 'furlongs',
'link' => 0.001, 'furlongs',
'fathom' => 6, 'feet',
'cable_length' => 123, 'fathoms',
);
=head2 Imperial
Imperial (english) units. The only unit included
in this set is "league".
=cut
__PACKAGE__->reg_units(
qw( league )
);
__PACKAGE__->reg_aliases(
'leagues' => 'league',
);
__PACKAGE__->reg_convs(
'league' => 3, 'miles',
);
=head2 Other
light_second
nautical_mile
=cut
__PACKAGE__->reg_units(
qw( light_second nautical_mile )
);
__PACKAGE__->reg_aliases(
'light_seconds' => 'light_second',
'nautical_miles' => 'nautical_mile',
);
__PACKAGE__->reg_convs(
'light_second' => 299792458, 'm',
'nautical_mile' => 1852, 'm',
);
1;
__END__
=head1 SUPPORT
See L<Class::Measure/SUPPORT>.
=head1 AUTHORS
See L<Class::Measure/AUTHORS>.
=head1 LICENSE
See L<Class::Measure/LICENSE>.
=cut
|