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   5728 use strict;
  26         76  
  26         780  
4 26     26   184 use warnings;
  26         75  
  26         1698  
5              
6             our ($VERSION, $AUTOLOAD);
7              
8             $VERSION = '1.08';
9              
10             sub __new
11             {
12 10580     10580   25625 my $class = shift;
13              
14 26     26   184 no strict 'refs';
  26         76  
  26         9287  
15              
16 10580         25653 my $obj = {};
17 10580         18873 $obj->{weekdays} = \%{"${class}::data_weekdays"};
  10580         59083  
18 10580         19677 $obj->{weekdays_abbrev} = \%{"${class}::data_weekdays_abbrev"};
  10580         37385  
19 10580         18577 $obj->{weekdays_all} = \@{"${class}::data_weekdays_all"};
  10580         37262  
20 10580         18933 $obj->{months} = \%{"${class}::data_months"};
  10580         33565  
21 10580         18380 $obj->{months_abbrev} = \%{"${class}::data_months_abbrev"};
  10580         33639  
22 10580         18065 $obj->{months_all} = \@{"${class}::data_months_all"};
  10580         34719  
23 10580         18181 $obj->{conversion} = \%{"${class}::data_conversion"};
  10580         34863  
24 10580         18725 $obj->{helpers} = \%{"${class}::data_helpers"};
  10580         42995  
25 10580         19429 $obj->{duration} = \%{"${class}::data_duration"};
  10580         32740  
26 10580         18280 $obj->{aliases} = \%{"${class}::data_aliases"};
  10580         31167  
27 10580         19041 $obj->{rewrite} = \%{"${class}::data_rewrite"};
  10580         32403  
28              
29 10580         36740 return bless $obj, $class;
30             }
31              
32             AUTOLOAD
33             {
34 1899864     1899864   11829189 my ($self, $exp) = @_;
35              
36 1899864         8622736 my ($caller, $sub) = $AUTOLOAD =~ /^(.+)::(.+)$/;
37              
38 1899864 100       6047370 if (substr($sub, 0, 2) eq '__') {
39 1889284         5146591 $sub =~ s/^__//;
40 26     26   227 no strict 'refs';
  26         81  
  26         2849  
41 1889284 100 66     6111399 if (defined $exp && length $exp) {
42 1878661         2753678 return ${$caller.'::'.$sub}{$exp};
  1878661         9787821  
43             }
44             else {
45 10623         17595 return \%{$caller.'::'.$sub};
  10623         137513  
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