File Coverage

blib/lib/Text/vCard/Precisely/V4/Node/Address.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Text::vCard::Precisely::V4::Node::Address;
2              
3 14     14   94 use Carp;
  14         35  
  14         1019  
4 14     14   87 use Moose;
  14         33  
  14         106  
5              
6             extends qw|Text::vCard::Precisely::V3::Node::Address Text::vCard::Precisely::V4::Node|;
7              
8             has name => ( is => 'ro', default => 'ADR', isa => 'Str' );
9             has content => ( is => 'ro', default => '', isa => 'Str' );
10              
11             has label => ( is => 'rw', isa => 'Str' );
12             has geo => ( is => 'rw', isa => 'Str' );
13              
14             my @order = @Text::vCard::Precisely::V3::Node::Address::order;
15              
16             override 'as_string' => sub {
17             my ($self) = @_;
18             my @lines;
19             push @lines, $self->name() || croak "Empty name";
20             push @lines, 'ALTID=' . $self->altID() if $self->can('altID') and $self->altID();
21             push @lines, 'PID=' . join ',', @{ $self->pid() } if $self->can('pid') and $self->pid();
22             push @lines, 'TYPE="' . join( ',', map {uc} @{ $self->types() } ) . '"'
23             if ref $self->types() eq 'ARRAY' and $self->types()->[0];
24             push @lines, 'PREF=' . $self->pref() if $self->pref();
25             push @lines, 'LANGUAGE=' . $self->language() if $self->language();
26             push @lines, 'LABEL="' . $self->label() . '"' if $self->label();
27             push @lines, 'GEO="' . $self->geo() . '"' if $self->geo();
28              
29             my $string = join( ';', @lines ) . ':' . join ';', map { $self->_escape( $self->$_ ) } @order;
30             return $self->fold($string);
31             };
32              
33             __PACKAGE__->meta->make_immutable;
34 14     14   90771 no Moose;
  14         415  
  14         86  
35              
36             1;