File Coverage

blib/lib/Text/vCard/Precisely/V4/Node/Image.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Text::vCard::Precisely::V4::Node::Image;
2              
3 14     14   100 use Carp;
  14         34  
  14         994  
4 14     14   5828 use Data::Validate::URI qw(is_web_uri);
  14         562781  
  14         903  
5              
6 14     14   299 use Moose;
  14         36  
  14         131  
7              
8             extends qw(Text::vCard::Precisely::V3::Node::Image Text::vCard::Precisely::V4::Node);
9              
10             has name => ( is => 'rw', default => 'PHOTO', isa => 'Str', required => 1 );
11             has content => ( is => 'rw', isa => 'Images', required => 1, coerce => 1 );
12             has media_type => ( is => 'rw', isa => 'Media_type' );
13              
14             override 'as_string' => sub {
15             my ($self) = @_;
16             my @lines;
17             push @lines, $self->name() || croak "Empty name";
18             push @lines, 'ALTID=' . $self->altID() if $self->altID();
19             push @lines, 'PID=' . join ',', @{ $self->pid() } if $self->pid();
20             push @lines, "MEDIATYPE=" . $self->media_type() if defined $self->media_type();
21             push @lines, "ENCODING=b" unless is_web_uri( $self->content() );
22              
23             my $string = join( ';', @lines ) . ':' . $self->content();
24             return $self->fold( $string, -force => 1 );
25             };
26              
27             __PACKAGE__->meta->make_immutable;
28 14     14   93095 no Moose;
  14         35  
  14         87  
29              
30             1;