| 1 | package Weather::OpenWeatherMap::Units; | ||
| 2 | 4 | $Weather::OpenWeatherMap::Units::VERSION = '0.003001'; | |
| 3 | 4 | ▶ | use feature 'state'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use strictures 2; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 4 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 4 | ▶ | use Types::Standard -all; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 4 | ▶ | use parent 'Exporter::Tiny'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 4 | our @EXPORT = our @EXPORT_OK = qw/ | |
| 11 | f_to_c | ||
| 12 | mph_to_kph | ||
| 13 | deg_to_compass | ||
| 14 | CoercedInt | ||
| 15 | /; | ||
| 16 | |||
| 17 | 12 | ▶ | sub f_to_c { ($_[0] - 32) * (5/9) } |
|
Subroutine
f_to_c: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | |||
| 19 | 8 | ▶ | sub mph_to_kph { $_[0] * 1.609344 } |
|
Subroutine
mph_to_kph: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 20 | |||
| 21 | sub deg_to_compass { | ||
| 22 | # I think I stole this from a stackoverflow answer I read, once. | ||
| 23 | # Credit where it's due except I can't recall where that might be... | ||
| 24 | 10 | ▶ | my $val = int( ($_[0] / 22.5) + 0.5 ); |
|
Subroutine
deg_to_compass: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 25 | 10 | state $compass = [qw/ | |
| 26 | N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW | ||
| 27 | /]; | ||
| 28 | 10 | $compass->[ $val % 16 ] | |
| 29 | } | ||
| 30 | |||
| 31 | # FIXME this needs to move to a proper typelib -> | ||
| 32 | 30 | ▶ | my $CoercedInt = Int->plus_coercions(StrictNum, sub { int }); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 33 | 35 | ▶ | sub CoercedInt { $CoercedInt } |
|
Subroutine
CoercedInt: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 34 | |||
| 35 | =pod | ||
| 36 | |||
| 37 | =for Pod::Coverage .* | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | 4 | 1; | |