File Coverage

blib/lib/Text/vCard/Precisely/V3/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::V3::Node::Address;
2              
3 28     28   8442 use Carp;
  28         71  
  28         2275  
4 28     28   193 use Moose;
  28         64  
  28         204  
5              
6             extends 'Text::vCard::Precisely::V3::Node';
7              
8             has name => ( is => 'ro', default => 'ADR', isa => 'Str' );
9             has content => ( is => 'ro', default => '', isa => 'Str' );
10              
11             our @order = qw( pobox extended street city region post_code country );
12             has \@order => ( is => 'rw', isa => 'Str' );
13              
14             override 'as_string' => sub {
15             my ($self) = @_;
16             my @lines;
17             push @lines, $self->name() || croak "Empty name";
18             push @lines, 'TYPE=' . join( ',', map { uc $_ } @{ $self->types() } )
19             if ref $self->types() eq 'ARRAY' and $self->types()->[0];
20             push @lines, 'PREF=' . $self->pref() if $self->pref();
21             push @lines, 'LANGUAGE=' . $self->language() if $self->language();
22              
23             my @values = ();
24             map { push @values, $self->_escape( $self->$_ ) } @order;
25             my $string = join( ';', @lines ) . ':' . join ';', @values;
26             return $self->fold($string);
27              
28             };
29              
30             __PACKAGE__->meta->make_immutable;
31 28     28   197135 no Moose;
  28         124  
  28         171  
32              
33             1;