diff options
Diffstat (limited to 'lib/WebService/ForecastIo/DataPoint.pm')
-rw-r--r-- | lib/WebService/ForecastIo/DataPoint.pm | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/WebService/ForecastIo/DataPoint.pm b/lib/WebService/ForecastIo/DataPoint.pm new file mode 100644 index 0000000..c05e981 --- /dev/null +++ b/lib/WebService/ForecastIo/DataPoint.pm @@ -0,0 +1,44 @@ +package WebService::ForecastIo::DataPoint; +use Moose; +use Moose::Util::TypeConstraints; + +class_type 'WebService::ForecastIo::DataPoint'; + +subtype 'WebService::ForecastIo::DataPointArray', + as 'ArrayRef[WebService::ForecastIo::DataPoint]'; + +coerce 'WebService::ForecastIo::DataPoint', from 'HashRef', + via { WebService::ForecastIo::DataPoint->new($_) }; + +coerce 'WebService::ForecastIo::DataPointArray', from 'ArrayRef[HashRef]', + via { + my $array = $_; + [ map { WebService::ForecastIo::DataPoint->new($_) } + @$array ] + }; + +has [qw( time + sunriseTime sunsetTime + precipIntensityMaxTime + temperatureMinTime temperatureMaxTime )] => ( + is => 'ro', + isa => 'Int', # time! +); + +has [qw(summary icon precipType)] => ( + is => 'ro', + isa => 'Str', +); + +has [qw( precipIntensity precipIntensityMax + precipProbability precipAccumulation + temperature temperatureMin temperatureMax + dewPoint humidity + windSpeed windBearing + cloudCover + pressure visibility ozone )] => ( + is => 'ro', + isa => 'Num', +); + +1; |