diff options
Diffstat (limited to 'lib/WebService/TFL/TubeStatus/Response')
-rw-r--r-- | lib/WebService/TFL/TubeStatus/Response/Line.pm | 36 | ||||
-rw-r--r-- | lib/WebService/TFL/TubeStatus/Response/LineStatus.pm | 32 |
2 files changed, 68 insertions, 0 deletions
diff --git a/lib/WebService/TFL/TubeStatus/Response/Line.pm b/lib/WebService/TFL/TubeStatus/Response/Line.pm new file mode 100644 index 0000000..11d3538 --- /dev/null +++ b/lib/WebService/TFL/TubeStatus/Response/Line.pm @@ -0,0 +1,36 @@ +package WebService::TFL::TubeStatus::Response::Line; +use Moose; +use WebService::TFL::TubeStatus::Response::LineStatus; +use namespace::autoclean; + +has id => ( + is => 'ro', + isa => 'Num', + required => 1, +); + +has name => ( + is => 'ro', + isa => 'Str', + required => 1, +); + +has status => ( + is => 'ro', + isa => 'WebService::TFL::TubeStatus::Response::LineStatus', + required => 1, +); + +sub new_from_xml { + my ($class,$line,$status,$xpath) = @_; + + my %init_arg; + + $init_arg{id} = $line->findvalue(q{@ID}); + $init_arg{name} = $line->findvalue(q{@Name}); + $init_arg{status} = WebService::TFL::TubeStatus::Response::LineStatus->new_from_xml($status,$xpath); + + return $class->new(\%init_arg); +} + +1; diff --git a/lib/WebService/TFL/TubeStatus/Response/LineStatus.pm b/lib/WebService/TFL/TubeStatus/Response/LineStatus.pm new file mode 100644 index 0000000..e223bb6 --- /dev/null +++ b/lib/WebService/TFL/TubeStatus/Response/LineStatus.pm @@ -0,0 +1,32 @@ +package WebService::TFL::TubeStatus::Response::LineStatus; +use Moose; +use namespace::autoclean; + +has is_active => ( + is => 'ro', + isa => 'Bool', + required => 1, +); + +has [qw(code class description details)] => ( + is => 'ro', + isa => 'Str', + required => 1, +); + +sub new_from_xml { + my ($class,$ls,$xpath) = @_; + + my %init_arg; + + my ($status) = $xpath->findnodes(q{ws:Status},$ls); + $init_arg{code} = $status->findvalue(q{@ID}); + $init_arg{is_active} = $status->findvalue(q{@IsActive}) eq 'true'; + $init_arg{class} = $status->findvalue(q{@CssClass}); + $init_arg{description} = $status->findvalue(q{@Description}); + $init_arg{details} = $ls->findvalue(q{@StatusDetails}); + + return $class->new(\%init_arg); +} + +1; |