Weather::Bug::CompactWeather - Simple class interface for a compact weather report.
This document describes Weather::Bug::CompactWeather version 0.25
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";
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.
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.
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.
Extract the weather information from an
aws:weather node, such as the ones returned by the getLiveCompactWeather WeatherBug request.
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.
The CompactWeather object provides accessor methods for the following fields:
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.
A Weather::Bug::Temperature object containing the current temperature.
A Weather::Bug::Quantity object containing the amount of rainfall detected today.
A Weather::Bug::Quantity object containing the current sustained windspeed.
A string listing the current sustained wind direction.
A Weather::Bug::Quantity object containing the windspeed of the most recent gust.
A string listing the direction of the most recent wind gust.
Unable to create a Station localizing the CompactWeather.
Weather::Bug requires no configuration files or environment variables.
No bugs have been reported.
Please report any bugs or feature requests to
firstname.lastname@example.org, or through the web interface at http://rt.cpan.org.
G. Wade Johnson
Copyright (c) 2008, G. Wade Johnson
<email@example.com>. 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.
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.