File Coverage

blib/lib/Parse/SAMGov/Entity/Address.pm
Criterion Covered Total %
statement 21 21 100.0
branch 10 10 100.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 37 37 100.0


line stmt bran cond sub pod time code
1             package Parse::SAMGov::Entity::Address;
2             $Parse::SAMGov::Entity::Address::VERSION = '0.104';
3 4     4   15 use strict;
  4         4  
  4         87  
4 4     4   12 use warnings;
  4         5  
  4         67  
5 4     4   51 use 5.010;
  4         8  
6 4     4   11 use Parse::SAMGov::Mo;
  4         4  
  4         25  
7              
8             #ABSTRACT: Defines the Address object of the entity.
9              
10              
11             use overload
12             fallback => 1,
13             '""' => sub {
14 47     47   53 my $str = '';
15 47 100       66 $str .= $_[0]->address . ', ' if length $_[0]->address;
16 47 100       70 $str .= $_[0]->city if length $_[0]->city;
17 47 100       66 $str .= ', ' . $_[0]->state if length $_[0]->state;
18 47 100       66 $str .= ', ' . $_[0]->country if length $_[0]->country;
19 47 100       69 $str .= ' - ' . $_[0]->zip if length $_[0]->zip;
20 47         101 return $str;
21 4     4   17 };
  4         6  
  4         33  
22              
23             has 'address';
24             has 'city';
25             has 'state';
26             has 'district';
27             has 'country';
28             has 'zip' => coerce => sub {
29             chop $_[0] if ($_[0] =~ /-$/);
30             return $_[0];
31             };
32              
33             1;
34              
35             =pod
36              
37             =encoding UTF-8
38              
39             =head1 NAME
40              
41             Parse::SAMGov::Entity::Address - Defines the Address object of the entity.
42              
43             =head1 VERSION
44              
45             version 0.104
46              
47             =head1 SYNOPSIS
48              
49             my $addr = Parse::SAMGov::Entity::Address->new(
50             address => '123 Baker Street, Suite 1A',
51             city => 'Boringville',
52             state => 'ZB',
53             country => 'USA',
54             zip => '21900-1234',
55             );
56              
57             =head1 METHODS
58              
59             =head2 new
60              
61             Creates a new Address object for the entity or individual.
62              
63             =head2 address
64              
65             This fields holds the address information without the city/state/country and
66             postal/zip code.
67              
68             =head2 city
69              
70             The city name of the entity's address.
71              
72             =head2 state
73              
74             The state or province of the entity's address.
75              
76             =head2 district
77              
78             The congressional district number of the entity's address.
79              
80             =head2 country
81              
82             The three character country code for the entity's address.
83              
84             =head2 zip
85              
86             The zip or postal code of the entity's address.
87              
88             =head1 AUTHOR
89              
90             Vikas N Kumar
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is copyright (c) 2016 by Selective Intellect LLC.
95              
96             This is free software; you can redistribute it and/or modify it under
97             the same terms as the Perl 5 programming language system itself.
98              
99             =cut
100              
101             __END__