File Coverage

blib/lib/Text/vCard/Precisely/V4/Node/N.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::N;
2              
3 14     14   105 use Carp;
  14         33  
  14         1220  
4 14     14   92 use Moose;
  14         36  
  14         118  
5              
6             my @order = qw( family given additional prefixes suffixes );
7              
8             extends qw|Text::vCard::Precisely::V3::Node::N Text::vCard::Precisely::V4::Node|;
9              
10             has sort_as => ( is => 'rw', isa => 'Str' );
11              
12             override 'as_string' => sub {
13             my ($self) = @_;
14             my @lines;
15             push @lines, $self->name() || croak "Empty name";
16             push @lines, 'ALTID=' . $self->altID() if $self->altID();
17             push @lines, 'PID=' . join ',', @{ $self->pid() } if $self->pid();
18             push @lines, 'LANGUAGE=' . $self->language() if $self->language();
19             push @lines, 'SORT-AS="' . $self->sort_as() . '"' if $self->sort_as();
20              
21             my @values = map { $self->_escape($_) }
22             map { $self->$_ or $self->content() && $self->content()->{$_} } @order;
23              
24             my $string = join( ';', @lines ) . ':' . join( ';', @values );
25             return $self->fold( $string, -force => 1 );
26             };
27              
28             __PACKAGE__->meta->make_immutable;
29 14     14   98020 no Moose;
  14         37  
  14         83  
30              
31             1;