OFC2/Title.pm

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
« OFC2/Scatter.pm ↑ Summary OFC2/ToolTip.pm »
1 package Chart::OFC2::Title;
2  
3 =head1 NAME
4  
5 Chart::OFC2::Title - OFC2 title object
6  
7 =head1 SYNOPSIS
8  
9 use Chart::OFC2;
10 use Chart::OFC2::Title;
11
12 $chart = Chart::OFC2->new(
13 'title' => 'Bar chart test',
14 );
15
16 $chart = Chart::OFC2->new(
17 'title' => Chart::OFC2::Title->new(
18 'text' => 'Bar chart test',
19 'style' => '{font-size:20px; font-family:Verdana; text-align:center;}',
20 ),
21 );
22  
23 =head1 DESCRIPTION
24  
25 =cut
26  
27 0 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=2.6
28 use Moose::Util::TypeConstraints;
29 use MooseX::StrictConstructor;
30  
31 our $VERSION = '0.07';
32  
33 coerce 'Chart::OFC2::Title'
34 => from 'Str'
35 => via { Chart::OFC2::Title->new('text' => $_) };
36  
37 =head1 PROPERTIES
38  
39 has 'text' => (is => 'rw', isa => 'Str', );
40 has 'style' => (is => 'rw', isa => 'Str', );
41  
42 =cut
43  
44 has 'text' => (is => 'rw', isa => 'Str', );
45 has 'style' => (is => 'rw', isa => 'Str', );
46  
47  
48 =head1 METHODS
49  
50 =head2 new()
51  
52 Object constructor.
53  
54 =head2 TO_JSON()
55  
56 Returns HashRef that is possible to give to C<encode_json()> function.
57  
58 =cut
59  
60 sub TO_JSON {
61 my $self = shift;
62
63 return {
64 map { my $v = $self->$_; (defined $v ? ($_ => $v) : ()) }
65 map { $_->name }
66 $self->meta->get_all_attributes
67 };
68 }
69  
70 __PACKAGE__->meta->make_immutable;
71  
72 1;
73  
74  
75 __END__
« OFC2/Scatter.pm ↑ Summary OFC2/ToolTip.pm »