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   102 use Carp;
  14         33  
  14         1082  
4 14     14   89 use Moose;
  14         29  
  14         106  
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->$_ or $self->content() && $self->content()->{$_} } @order;
22             my $string = join( ';', @lines ) . ':' . join ';', map { $self->_escape($_) } @values;
23             return $self->fold( $string, -force => 1 );
24             };
25              
26             __PACKAGE__->meta->make_immutable;
27 14     14   89568 no Moose;
  14         33  
  14         74  
28              
29             1;