File Coverage

blib/lib/Data/InfoBox.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 21 22 95.4


line stmt bran cond sub pod time code
1             package Data::InfoBox;
2              
3 24     24   139334 use strict;
  24         53  
  24         962  
4 24     24   125 use warnings;
  24         39  
  24         1489  
5              
6 24     24   10759 use Mo qw(build is);
  24         16360  
  24         140  
7 24     24   52807 use Mo::utils::Array qw(check_array_object check_array_required);
  24         435415  
  24         1670  
8              
9             our $VERSION = 0.07;
10              
11             has items => (
12             is => 'ro',
13             );
14              
15             sub BUILD {
16 17     17 0 10712 my $self = shift;
17              
18             # Check items.
19 17         99 check_array_object($self, 'items', 'Data::InfoBox::Item');
20 16         922 check_array_required($self, 'items');
21              
22 14         227 return;
23             }
24              
25             1;
26              
27             __END__
28              
29             =pod
30              
31             =encoding utf8
32              
33             =head1 NAME
34              
35             Data::InfoBox - Data object for info box.
36              
37             =head1 DESCRIPTION
38              
39             Data object for definition of common infobox which contains lines with
40             informations. The informations are in form of text description (optionaly with icon and link).
41              
42             =head1 SYNOPSIS
43              
44             use Data::InfoBox;
45              
46             my $obj = Data::InfoBox->new(%params);
47             my $items_ar = $obj->items;
48              
49             =head1 METHODS
50              
51             =head2 C<new>
52              
53             my $obj = Data::InfoBox->new(%params);
54              
55             Constructor.
56              
57             =over 8
58              
59             =item * C<items>
60              
61             List of L<Data::InfoBox::Item> items. Must be as reference to array.
62              
63             It's required.
64              
65             =back
66              
67             Returns instance of object.
68              
69             =head2 C<items>
70              
71             my $items_ar = $obj->items;
72              
73             Get list of items in info box.
74              
75             Returns reference to array with L<Data::InfoBox::Item> objects.
76              
77             =head1 ERRORS
78              
79             new():
80             From Mo::utils::Array::check_array_object():
81             Parameter 'items' must be a array.
82             Value: %s
83             Reference: %s
84             Parameter 'items' with array must contain 'Data::InfoBox::Item' objects.
85             Value: %s
86             Reference: %s
87             From Mo::utils::Array::check_array_required():
88             Parameter 'items' is required.
89             Parameter 'items' with array must have at least one item.
90              
91              
92             =head1 EXAMPLE
93              
94             =for comment filename=create_infobox_object_and_print.pl
95              
96             use strict;
97             use warnings;
98              
99             use Data::InfoBox;
100             use Data::InfoBox::Item;
101             use Data::Text::Simple;
102              
103             my $obj = Data::InfoBox->new(
104             'items' => [
105             Data::InfoBox::Item->new(
106             'text' => Data::Text::Simple->new(
107             'text' => 'First item',
108             ),
109             ),
110             Data::InfoBox::Item->new(
111             'text' => Data::Text::Simple->new(
112             'text' => 'Second item',
113             ),
114             ),
115             ],
116             );
117              
118             # Print out.
119             my $num = 0;
120             foreach my $item (@{$obj->items}) {
121             $num++;
122             print "Item $num: ".$item->text->text."\n";
123             }
124              
125             # Output:
126             # Item 1: First item
127             # Item 2: Second item
128              
129             =head1 DEPENDENCIES
130              
131             L<Mo>,
132             L<Mo::utils::Array>.
133              
134             =head1 SEE ALSO
135              
136             =over
137              
138             =item L<Data::InfoBox::Item>
139              
140             Data object for info box item.
141              
142             =item L<Tags::HTML::InfoBox>
143              
144             Tags helper for HTML info box.
145              
146             =item L<Test::Shared::Fixture::Data::InfoBox::Street>
147              
148             Street info box fixture.
149              
150             =back
151              
152             =head1 REPOSITORY
153              
154             L<https://github.com/michal-josef-spacek/Data-InfoBox>
155              
156             =head1 AUTHOR
157              
158             Michal Josef Špaček L<mailto:skim@cpan.org>
159              
160             L<http://skim.cz>
161              
162             =head1 LICENSE AND COPYRIGHT
163              
164             © 2024-2025 Michal Josef Špaček
165              
166             BSD 2-Clause License
167              
168             =head1 VERSION
169              
170             0.07
171              
172             =cut