| 1 | package Weather::YR::Model::Temperature; | ||
| 2 | 3 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 3 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 3 | extends 'Weather::YR::Model'; | |
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Weather::YR::Model::Temperature | ||
| 10 | |||
| 11 | =head1 DESCRIPTION | ||
| 12 | |||
| 13 | This class represents a data point's "temperature". | ||
| 14 | |||
| 15 | =head1 METHODS | ||
| 16 | |||
| 17 | This class inherits all the methods from L<Weather::YR::Model> and provides the | ||
| 18 | following new methods: | ||
| 19 | |||
| 20 | =head2 celsius | ||
| 21 | |||
| 22 | Returns the current data point's temperature in celsius. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | 3 | has 'celsius' => ( | |
| 27 | isa => 'Num', | ||
| 28 | is => 'ro', | ||
| 29 | required => 1, | ||
| 30 | ); | ||
| 31 | |||
| 32 | =head2 fahrenheit | ||
| 33 | |||
| 34 | Returns the current data point's temperature in fahrenheit. | ||
| 35 | |||
| 36 | =cut | ||
| 37 | |||
| 38 | sub fahrenheit { | ||
| 39 | 0 | ▶ | my $self = shift; |
|
Subroutine
fahrenheit: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 40 | |||
| 41 | 0 | my $fahrenheit = ( ($self->celsius * 9) / 5 ) + 32; | |
| 42 | |||
| 43 | 0 | return sprintf( '%.2f', $fahrenheit ); | |
| 44 | } | ||
| 45 | |||
| 46 | =head2 kelvin | ||
| 47 | |||
| 48 | Returns the current data point's temperature in kelvin. | ||
| 49 | |||
| 50 | =cut | ||
| 51 | |||
| 52 | sub kelvin { | ||
| 53 | 0 | ▶ | my $self = shift; |
|
Subroutine
kelvin: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 54 | |||
| 55 | 0 | return sprintf( '%.2f', $self->celsius + 273.15 ); | |
| 56 | } | ||
| 57 | |||
| 58 | # | ||
| 59 | # The End | ||
| 60 | # | ||
| 61 | 3 | __PACKAGE__->meta->make_immutable; | |
| 62 | |||
| 63 | 3 | 1; | |