File Coverage

blib/lib/NewsExtractor/Article.pm
Criterion Covered Total %
statement 6 8 75.0
branch n/a
condition n/a
subroutine 2 3 66.6
pod 0 1 0.0
total 8 12 66.6


line stmt bran cond sub pod time code
1             package NewsExtractor::Article;
2 1     1   8 use Moo;
  1         2  
  1         8  
3 1     1   324 use NewsExtractor::Types qw< Text Text1K >;
  1         3  
  1         8  
4              
5             has headline => ( required => 1, is => 'ro', isa => Text1K );
6             has article_body => ( required => 1, is => 'ro', isa => Text );
7              
8             has dateline => ( predicate => 1, is => 'ro', isa => Text1K );
9             has journalist => ( predicate => 1, is => 'ro', isa => Text1K );
10              
11             sub TO_JSON {
12 0     0 0   my ($self) = @_;
13             return {
14 0           headline => $self->headline,
15             article_body => $self->article_body,
16             dateline => $self->dateline,
17             journalist => $self->journalist,
18             }
19             }
20              
21             1;
22              
23             __END__
24              
25             =head1 Name
26              
27             NewsExtractor::Article - A data class for containing news article.
28              
29             =head1 Description
30              
31             This is a data class that contains an news article extracted from some web sites.
32             The instances of this data class has these attributes:
33              
34             =over 4
35              
36             =item headline
37              
38             Mandatory. Str. Refer to the headline of a news article.
39              
40             =item article_body
41              
42             Mandatory. Str. Refer to the body of a news article.
43              
44             =item dateline
45              
46             Optional. One must check the presense of this attribute with C<has_dateline>
47             method before taking the value of it.
48              
49             =item journalist
50              
51             Optional. One must check the presense of this attribute with C<has_journalist>
52             method before taking the value of it.
53              
54             =back
55              
56             =cut