OpenGbg/Service/Bridge/BridgeOpening.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod n/a totaltotal 90.7% 39 / 43 CC 1 SCAR 1.8
CC
1
Cov
94%
_build_timestamp
2.0
_build_was_open
2.0
BEGIN
1.0
CRAP 1.2
« OpenGbg/Service/TrafficCamera/GetCameraImage.pm ↑ Summary OpenGbg/Service/Bridge/GetIsCurrentlyOpen.pm »
1 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package OpenGbg::Service::Bridge::BridgeOpening;
6  
7 # ABSTRACT: A change in status for Göta Älvbron
8 1 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 1 our $VERSION = '0.1402';
10  
11 1 ▶use XML::Rabbit;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use DateTime::Format::HTTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use MooseX::AttributeShortcuts;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use OpenGbg::DateTimeType qw/DateTime/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Types::Standard qw/Bool/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 has_xpath_value _timestamp => './x:TimeStamp';
18  
19 1 has_xpath_value _was_open => './x:Value';
20  
21 1 has timestamp => (
22 is => 'ro',
23 isa => DateTime,
24 lazy => 1,
25 builder => 1,
26 );
27  
28 1 has was_open => (
29 is => 'ro',
30 isa => Bool,
31 lazy => 1,
32 builder => 1,
33 );
34  
35 sub _build_timestamp {
36 0 ▶ return DateTime::Format::HTTP->parse_datetime(shift->_timestamp);
Subroutine _build_timestamp: not called CC=1 SCAR=6.9
37 }
38 sub _build_was_open {
39 0 ▶ return shift->_was_open eq 'true';
Subroutine _build_was_open: not called CC=1 SCAR=6.9
40 }
41  
42 1 finalize_class();
43  
44 1 1;
45  
46 __END__
47  
48 =pod
49  
50 =encoding utf-8
51  
52 =head1 NAME
53  
54 OpenGbg::Service::Bridge::BridgeOpening - A change in status for Göta Älvbron
55  
56 =head1 VERSION
57  
58 Version 0.1402, released 2016-08-12.
59  
60 =head1 SYNOPSIS
61  
62 my $bridge = OpenGbg->new->bridge;
63 my $status = $bridge->get_opened_status->get_by_index(2);
64  
65 printf 'it was %s', $status->was_open ? 'open' : 'closed';
66  
67 =head1 DESCRIPTIOn
68  
69 Each C<BridgeOpening> object only knows if the bridge was opened or closed at that time. Usually, an 'open' BridgeOpening is followed a few minutes later by a 'closed' one.
70  
71 =head1 ATTRIBUTES
72  
73 =head2 timestamp
74  
75 A L<DateTime> object.
76  
77 The time the bridge was either open or closed.
78  
79 =head2 was_open
80  
81 Boolean. True if the bridge was open at C<timestamp>, false if not.
82  
83 =head1 SOURCE
84  
85 L<https://github.com/Csson/p5-OpenGbg>
86  
87 =head1 HOMEPAGE
88  
89 L<https://metacpan.org/release/OpenGbg>
90  
91 =head1 AUTHOR
92  
93 Erik Carlsson <info@code301.com>
94  
95 =head1 COPYRIGHT AND LICENSE
96  
97 This software is copyright (c) 2016 by Erik Carlsson.
98  
99 This is free software; you can redistribute it and/or modify it under
100 the same terms as the Perl 5 programming language system itself.
101  
102 =cut
« OpenGbg/Service/TrafficCamera/GetCameraImage.pm ↑ Summary OpenGbg/Service/Bridge/GetIsCurrentlyOpen.pm »