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   5743 use strict;
  26         81  
  26         766  
4 26     26   160 use warnings;
  26         57  
  26         1623  
5              
6             our ($VERSION, $AUTOLOAD);
7              
8             $VERSION = '1.08';
9              
10             sub __new
11             {
12 10581     10581   25077 my $class = shift;
13              
14 26     26   185 no strict 'refs';
  26         61  
  26         8631  
15              
16 10581         22231 my $obj = {};
17 10581         18655 $obj->{weekdays} = \%{"${class}::data_weekdays"};
  10581         56568  
18 10581         19545 $obj->{weekdays_abbrev} = \%{"${class}::data_weekdays_abbrev"};
  10581         39686  
19 10581         18796 $obj->{weekdays_all} = \@{"${class}::data_weekdays_all"};
  10581         35249  
20 10581         18598 $obj->{months} = \%{"${class}::data_months"};
  10581         33341  
21 10581         19361 $obj->{months_abbrev} = \%{"${class}::data_months_abbrev"};
  10581         33528  
22 10581         19072 $obj->{months_all} = \@{"${class}::data_months_all"};
  10581         32620  
23 10581         17779 $obj->{conversion} = \%{"${class}::data_conversion"};
  10581         32795  
24 10581         17632 $obj->{helpers} = \%{"${class}::data_helpers"};
  10581         41878  
25 10581         18888 $obj->{duration} = \%{"${class}::data_duration"};
  10581         33092  
26 10581         17892 $obj->{aliases} = \%{"${class}::data_aliases"};
  10581         31951  
27 10581         17869 $obj->{rewrite} = \%{"${class}::data_rewrite"};
  10581         30834  
28              
29 10581         35746 return bless $obj, $class;
30             }
31              
32             AUTOLOAD
33             {
34 1798808     1798808   11311024 my ($self, $exp) = @_;
35              
36 1798808         8419364 my ($caller, $sub) = $AUTOLOAD =~ /^(.+)::(.+)$/;
37              
38 1798808 100       6017759 if (substr($sub, 0, 2) eq '__') {
39 1788227         5096849 $sub =~ s/^__//;
40 26     26   241 no strict 'refs';
  26         89  
  26         2739  
41 1788227 100 66     6002323 if (defined $exp && length $exp) {
42 1777604         2638609 return ${$caller.'::'.$sub}{$exp};
  1777604         9713357  
43             }
44             else {
45 10623         17627 return \%{$caller.'::'.$sub};
  10623         138899  
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