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   7650 use Carp;
  28         70  
  28         2022  
4 28     28   196 use Moose;
  28         60  
  28         194  
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   183246 no Moose;
  28         119  
  28         156  
32              
33             1;