Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhthorsen/mojo-yr
Get weather information from yr.no
https://github.com/jhthorsen/mojo-yr
Last synced: 27 days ago
JSON representation
Get weather information from yr.no
- Host: GitHub
- URL: https://github.com/jhthorsen/mojo-yr
- Owner: jhthorsen
- Created: 2014-04-12T10:00:43.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-12T08:05:38.000Z (over 6 years ago)
- Last Synced: 2024-10-16T11:58:29.460Z (3 months ago)
- Language: Perl
- Size: 18.6 KB
- Stars: 0
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
Mojo::YR - Get weather information from yr.noDESCRIPTION
Mojo::YR is an (a)synchronous weather data fetcher for the Mojolicious
framework. The backend for weather data is .Look at the resources below for mere information about the API:
*
*
*
SYNOPSIS
use Mojo::YR;
my $yr = Mojo::YR->new;# Fetch location_forecast ==========================================
my $now = $yr->location_forecast([59, 10])->find('pointData > time')->first;
my $temp = $now->at('temperature');warn "$temp->{value} $temp->{unit}";
# Fetch text_forecast ==============================================
my $today = $yr->text_forecast->children('time')->first;
my $hordaland = $today->at('area[name="Hordaland"]');warn $hordaland->at('header')->text;
warn $hordaland->at('in')->text; # "in" holds the forecast textATTRIBUTES
url_map
$hash_ref = $self->url_map;Returns the URL used to fetch data.
Note: These will always be what you expect. If the resources get changed
in the future, a "version()" attribute will be added to this class to
ensure you always get the same URL map.Default:
{
location_forecast => 'http://api.yr.no/weatherapi/locationforecast/1.8/',
text_forecast => 'http://api.yr.no/weatherapi/textforecast/1.6/',
};METHODS
location_forecast
$self = $self->location_forecast([$latitude, $longitude], sub { my($self, $err, $dom) = @_; ... });
$self = $self->location_forecast(\%args, sub { my($self, $err, $dom) = @_; ... });
$dom = $self->location_forecast([$latitude, $longitude]);
$dom = $self->location_forecast(\%args);Used to fetch weather forecast for a specified place
.%args is required (unless "[$latitude,$longitude]" is given):
{
latitude => $num,
longitude => $num,
}$dom is a Mojo::DOM object you can use to query the result. See
"SYNOPSIS" for example.text_forecast
$dom = $self->text_forecast(\%args);
$self = $self->text_forecast(\%args, sub { my($self, $err, $dom) = @_; ... });Used to fetch textual weather forecast for all parts of the country
.%args is optional and has these default values:
{
forecast => 'land',
language => 'nb',
}$dom is a Mojo::DOM object you can use to query the result. See
"SYNOPSIS" for example.COPYRIGHT AND LICENSE
Copyright (C) 2014 Jan Henning ThorsenThis program is free software, you can redistribute it and/or modify it
under the terms of the Artistic License version 2.0.AUTHOR
Jan Henning Thorsen - "[email protected]"