File Coverage

blib/lib/DateTime/Format/Natural/Lang/Base.pm
Criterion Covered Total %
statement 46 46 100.0
branch 4 4 100.0
condition 2 3 66.6
subroutine 6 6 100.0
pod n/a
total 58 59 98.3


line stmt bran cond sub pod time code
1             package DateTime::Format::Natural::Lang::Base;
2              
3 26     26   6549 use strict;
  26         60  
  26         1108  
4 26     26   172 use warnings;
  26         103  
  26         2939  
5              
6             our ($VERSION, $AUTOLOAD);
7              
8             $VERSION = '1.08';
9              
10             sub __new
11             {
12 10812     10812   32714 my $class = shift;
13              
14 26     26   233 no strict 'refs';
  26         61  
  26         11608  
15              
16 10812         27118 my $obj = {};
17 10812         23836 $obj->{weekdays} = \%{"${class}::data_weekdays"};
  10812         86789  
18 10812         26581 $obj->{weekdays_abbrev} = \%{"${class}::data_weekdays_abbrev"};
  10812         56646  
19 10812         24387 $obj->{weekdays_all} = \@{"${class}::data_weekdays_all"};
  10812         58722  
20 10812         23179 $obj->{months} = \%{"${class}::data_months"};
  10812         50506  
21 10812         23306 $obj->{months_abbrev} = \%{"${class}::data_months_abbrev"};
  10812         49318  
22 10812         26103 $obj->{months_all} = \@{"${class}::data_months_all"};
  10812         50391  
23 10812         20966 $obj->{conversion} = \%{"${class}::data_conversion"};
  10812         58291  
24 10812         21778 $obj->{helpers} = \%{"${class}::data_helpers"};
  10812         51343  
25 10812         25350 $obj->{duration} = \%{"${class}::data_duration"};
  10812         49404  
26 10812         22521 $obj->{aliases} = \%{"${class}::data_aliases"};
  10812         48104  
27 10812         22538 $obj->{rewrite} = \%{"${class}::data_rewrite"};
  10812         52851  
28              
29 10812         57943 return bless $obj, $class;
30             }
31              
32             AUTOLOAD
33             {
34 2044986     2044986   17068388 my ($self, $exp) = @_;
35              
36 2044986         11011661 my ($caller, $sub) = $AUTOLOAD =~ /^(.+)::(.+)$/;
37              
38 2044986 100       8184471 if (substr($sub, 0, 2) eq '__') {
39 2034174         5555141 $sub =~ s/^__//;
40 26     26   230 no strict 'refs';
  26         81  
  26         3640  
41 2034174 100 66     7395401 if (defined $exp && length $exp) {
42 2023340         3284185 return ${$caller.'::'.$sub}{$exp};
  2023340         14689191  
43             }
44             else {
45 10834         21949 return \%{$caller.'::'.$sub};
  10834         225692  
46             }
47             }
48             }
49              
50             1;
51             __END__
52              
53             =head1 NAME
54              
55             DateTime::Format::Natural::Lang::Base - Base class for DateTime::Format::Natural::Lang::
56              
57             =head1 SYNOPSIS
58              
59             Please see the DateTime::Format::Natural::Lang:: documentation.
60              
61             =head1 DESCRIPTION
62              
63             The C<DateTime::Format::Natural::Lang::Base> class defines the core functionality for
64             C<DateTime::Format::Natural::Lang::> grammar classes.
65              
66             =head1 SEE ALSO
67              
68             L<DateTime::Format::Natural>
69              
70             =head1 AUTHOR
71              
72             Steven Schubiger <schubiger@cpan.org>
73              
74             =head1 LICENSE
75              
76             This program is free software; you may redistribute it and/or
77             modify it under the same terms as Perl itself.
78              
79             See L<http://dev.perl.org/licenses/>
80              
81             =cut