Skip to content

Commit

Permalink
temp/temp_f interchangable in Current and Hourly results
Browse files Browse the repository at this point in the history
  • Loading branch information
avenj committed Jan 1, 2016
1 parent 7d228b9 commit b954758
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Weather/OpenWeatherMap/Result/Current.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ has longitude => ( lazy_for StrictNum,
has temp_f => ( lazy_for Int,
builder => sub { int( shift->data->{main}->{temp} ) },
);
sub temp { shift->temp_f }

has temp_c => ( lazy_for Int,
builder => sub { int f_to_c( shift->temp_f ) },
Expand Down
3 changes: 2 additions & 1 deletion lib/Weather/OpenWeatherMap/Result/Forecast/Hour.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ has temp => (
coerce => 1,
builder => sub { shift->_main->{temp} },
);
sub temp_f { shift->temp }

has temp_c => (
lazy => 1,
Expand Down Expand Up @@ -164,7 +165,7 @@ provided by the OpenWeatherMap service.
See also: L<Weather::OpenWeatherMap::Result::Forecast::Block/dt>
=head3 temp
=head3 temp_f
The predicted temperature (in Fahrenheit).
Expand Down
2 changes: 2 additions & 0 deletions t/inc/Testing/Result/Current.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ test 'temperatures' => sub {
# temp_f, temp_c
cmp_ok $self->result_obj->temp_f, '==', 41,
'temp_f';
cmp_ok $self->result_obj->temp, '==', $self->result_obj->temp_f,
'temp aliased to temp_f';
cmp_ok $self->result_obj->temp_c, '==', 5,
'temp_c';
};
Expand Down
6 changes: 4 additions & 2 deletions t/inc/Testing/Result/Forecast/Hourly.pm
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ test 'atmospheric' => sub {
test 'conditions' => sub {
my ($self) = @_;

cmp_ok $self->first->temp, '==', 33,
'temp';
cmp_ok $self->first->temp_f, '==', 33,
'temp_f';
cmp_ok $self->first->temp, '==', $self->first->temp_f,
'temp aliased to temp_f';
cmp_ok $self->first->temp_c, '==', 0,
'temp_c';

Expand Down

0 comments on commit b954758

Please sign in to comment.