NAME
Weather::Bug::CompactWeather - Simple class interface for a compact weather report.
VERSION
This document describes Weather::Bug::CompactWeather version 0.20
SYNOPSIS
use Weather::Bug;
my $wbug = Weather::Bug->new( 'YOURAPIKEYHERE' );
my $weather = $wbug->get_live_compact_weather( 'HSTMU', 77030 );
my $temp = $weather->temp();
my $rain = $weather->rain_today();
my $wind = $weather->wind_speed();
my $dir = $weather->wind_dir();
print "Temperature: $temp\n",
"Rain: $rain\n",
"Wind: $wind from $dir\n";
DESCRIPTION
The CompactWeather class wraps the concept of a WeatherBug weather report. The WeatherBug API provides two different weather reports: Live Compact, and Live. This object wraps the compact form which contains the basic information you may want from a weather observation.
INTERFACE
The CompactWeather interface provides a factory method that constructs the object from an XML node. It also provides accessor methods for the various pieces of data comprising the weather observation.
Factory Method
Since the CompactWeather object will almost always be created from an XML stream, this class provides a method for constructing a CompactWeather object from the XML response.
- from_xml
-
Extract the weather information from an
aws:weather
node, such as the ones returned by the getLiveCompactWeather WeatherBug request.$bug - the Weather::Bug object $w - the
aws:weather
XML node $creator - either a Weather::Bug::Station or aWeather::Bug
object.If we get a Station, use it internally, otherwise we need to parse the XML to create a station object.
Return a new Weather::Bug::CompactWeather object. Dies on failure.
Accessor Methods
The CompactWeather object provides accessor methods for the following fields:
- station
-
A Weather::Bug::Station object describing the location of the observation. The amount of information in this Station object is determined by how the CompactWeather was created. Weather::Bug::Station::get_live_compact_weather returns the Station used in the request. Weather::Bug::get_live_compact_weather returns a simpler Station object created from the XML stream.
- temp
-
A Weather::Bug::Temperature object containing the current temperature.
- rain_today
-
A Weather::Bug::Quantity object containing the amount of rainfall detected today.
- wind_speed
-
A Weather::Bug::Quantity object containing the current sustained windspeed.
- wind_dir
-
A string listing the current sustained wind direction.
- gust_speed
-
A Weather::Bug::Quantity object containing the windspeed of the most recent gust.
- gust_dir
-
A string listing the direction of the most recent wind gust.
DIAGNOSTICS
Unable to create a Station localizing the CompactWeather.
-
The from_xml method was unable to create a Station object from the incoming XML or the creator object was neither a Weather::Bug nor a Weather::Bug::Station object.
CONFIGURATION AND ENVIRONMENT
Weather::Bug requires no configuration files or environment variables.
DEPENDENCIES
Moose
, XML::LibXML
INCOMPATIBILITIES
None reported.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to bug-weather-weatherbug@rt.cpan.org
, or through the web interface at http://rt.cpan.org.
AUTHOR
G. Wade Johnson <wade@anomaly.org>
LICENCE AND COPYRIGHT
Copyright (c) 2008, G. Wade Johnson <wade@anomaly.org>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.