SoggyOnion::Plugin::GeoWeather - get the weather


SoggyOnion documentation Contained in the SoggyOnion distribution.

Index


Code Index:

NAME

Top

SoggyOnion::Plugin::GeoWeather - get the weather

SYNOPSIS

Top

In config.yaml:

    layout:
      - title: Weather
        name:  weather.html
        items:

          - plugin: SoggyOnion::Plugin::GeoWeather
            id: weatherdotcom
            zip: '02115'

 ..or..

          - plugin: SoggyOnion::Plugin::GeoWeather
            id: weatherdotcom
            city: Boston
            state: MA

DESCRIPTION

Top

This is a plugin for SoggyOnion that gets the weather.

Item Options

* id - the item ID that appears in the HTML <DIV> tag
* zip
* city and state

SEE ALSO

Top

SoggyOnion

AUTHOR

Top

Ian Langworth, <ian@cpan.org>

COPYRIGHT AND LICENSE

Top


SoggyOnion documentation Contained in the SoggyOnion distribution.

package SoggyOnion::Plugin::GeoWeather;
use warnings;
use strict;
use base qw( SoggyOnion::Plugin );

our $VERSION = '0.04';

use Geo::Weather;

sub content {
    my $self = shift;

    # we need either the city&state or a zip code
    my @args;
    if ( exists $self->{zip} ) {
        @args = ( $self->{zip} );
    }
    elsif ( exists $self->{city} && exists $self->{state} ) {
        @args = ( $self->{city}, $self->{state} );
    }
    else {
        warn __PACKAGE__ . " hash must have 'zip' or 'city' and 'state'\n";
        return;
    }

    # get the weather
    my $weather = Geo::Weather->new;
    $weather->get_weather(@args);
    return $weather->report . "<hr/>" . $weather->report_forecast;
}

1;

__END__