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   118 use Carp;
  14         33  
  14         1175  
4 14     14   94 use Moose;
  14         33  
  14         117  
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 @values = ();
30             map { push @values, $self->_escape( $self->$_ ) } @order;
31             my $string = join( ';', @lines ) . ':' . join ';', @values;
32             return $self->fold($string);
33              
34             };
35              
36             __PACKAGE__->meta->make_immutable;
37 14     14   102201 no Moose;
  14         390  
  14         118  
38              
39             1;