| 1 | package Weather::Bug::Forecast; | ||||||||||
| 2 | |||||||||||
| 3 | 12 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 12 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 12 | ▶ | use XML::LibXML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 12 | ▶ | use Weather::Bug::Temperature; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 12 | our $VERSION = '0.25'; | |||||||||
| 10 | |||||||||||
| 11 | 12 | has 'title' => ( is => 'ro', isa => 'Str', init_arg => '-title' ); | |||||||||
| 12 | 12 | has 'short_title' => ( is => 'ro', isa => 'Str', init_arg => '-short' ); | |||||||||
| 13 | 12 | has 'imageurl' => ( is => 'ro', isa => 'Str', init_arg => '-image' ); | |||||||||
| 14 | 12 | has 'description' => ( is => 'ro', isa => 'Str', init_arg => '-desc' ); | |||||||||
| 15 | 12 | has 'prediction' => ( is => 'ro', isa => 'Str', init_arg => '-pred' ); | |||||||||
| 16 | 12 | has 'high' => ( is => 'ro', isa => 'Weather::Bug::Temperature', init_arg => '-high' ); | |||||||||
| 17 | 12 | has 'low' => ( is => 'ro', isa => 'Weather::Bug::Temperature', init_arg => '-low' ); | |||||||||
| 18 | |||||||||||
| 19 | sub from_xml | ||||||||||
| 20 | 39 | ▶ | { | ||||||||
|
Subroutine
from_xml: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 21 | 39 | my $class = shift; | |||||||||
| 22 | 39 | my $node = shift; | |||||||||
| 23 | |||||||||||
| 24 | 39 | my ($hi) = $node->findnodes( 'aws:high' ); | |||||||||
| 25 | 39 | my ($lo) = $node->findnodes( 'aws:low' ); | |||||||||
| 26 | |||||||||||
| 27 | 39 | ▶ | die "No 'aws:high' node found.\n" unless defined $hi; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 39 | ▶ | die "No 'aws:low' node found.\n" unless defined $lo; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | |||||||||||
| 30 | 39 | return Weather::Bug::Forecast->new( | |||||||||
| 31 | -title => $node->findvalue( 'aws:title' ), | ||||||||||
| 32 | -short => $node->findvalue( 'aws:short-title' ), | ||||||||||
| 33 | -image => $node->findvalue( 'aws:image' ), | ||||||||||
| 34 | -desc => $node->findvalue( 'aws:description' ), | ||||||||||
| 35 | -pred => $node->findvalue( 'aws:prediction' ), | ||||||||||
| 36 | -high => Weather::Bug::Temperature->from_xml( $hi ), | ||||||||||
| 37 | -low => Weather::Bug::Temperature->from_xml( $lo ), | ||||||||||
| 38 | ); | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 12 | 1; # Magic true value required at end of module | |||||||||
| 42 | __END__ | ||||||||||