File Coverage

blib/lib/Toolforge/MixNMatch/Struct/YearMonth.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package Toolforge::MixNMatch::Struct::YearMonth;
2              
3 8     8   338191 use strict;
  8         90  
  8         243  
4 8     8   44 use warnings;
  8         17  
  8         220  
5              
6 8     8   3034 use Toolforge::MixNMatch::Object::YearMonth;
  8         51981  
  8         1460  
7              
8             our $VERSION = 0.03;
9              
10             sub obj2struct {
11 3     3 0 191 my $obj = shift;
12              
13 3         13 my $struct_hr = {
14             'cnt' => $obj->count,
15             'ym' => $obj->year.(sprintf '%02d', $obj->month),
16             };
17              
18 3         66 return $struct_hr;
19             }
20              
21             sub struct2obj {
22 3     3 0 105 my $struct_hr = shift;
23              
24 3         23 my ($year, $month) = $struct_hr->{'ym'} =~ m/^(\d{4})(\d{2})$/ms;
25             my $obj = Toolforge::MixNMatch::Object::YearMonth->new(
26 3         28 'count' => $struct_hr->{'cnt'},
27             'month' => int($month),
28             'year' => $year,
29             );
30              
31 3         226 return $obj;
32             }
33              
34             1;
35              
36             __END__