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   6173 use strict;
  26         69  
  26         779  
4 26     26   171 use warnings;
  26         76  
  26         1791  
5              
6             our ($VERSION, $AUTOLOAD);
7              
8             $VERSION = '1.08';
9              
10             sub __new
11             {
12 10581     10581   24724 my $class = shift;
13              
14 26     26   173 no strict 'refs';
  26         79  
  26         9179  
15              
16 10581         22930 my $obj = {};
17 10581         18532 $obj->{weekdays} = \%{"${class}::data_weekdays"};
  10581         59068  
18 10581         20549 $obj->{weekdays_abbrev} = \%{"${class}::data_weekdays_abbrev"};
  10581         38459  
19 10581         19242 $obj->{weekdays_all} = \@{"${class}::data_weekdays_all"};
  10581         35985  
20 10581         17766 $obj->{months} = \%{"${class}::data_months"};
  10581         34903  
21 10581         19806 $obj->{months_abbrev} = \%{"${class}::data_months_abbrev"};
  10581         34454  
22 10581         18772 $obj->{months_all} = \@{"${class}::data_months_all"};
  10581         33574  
23 10581         18980 $obj->{conversion} = \%{"${class}::data_conversion"};
  10581         33970  
24 10581         18021 $obj->{helpers} = \%{"${class}::data_helpers"};
  10581         44135  
25 10581         18769 $obj->{duration} = \%{"${class}::data_duration"};
  10581         34886  
26 10581         17761 $obj->{aliases} = \%{"${class}::data_aliases"};
  10581         32361  
27 10581         18456 $obj->{rewrite} = \%{"${class}::data_rewrite"};
  10581         32645  
28              
29 10581         38352 return bless $obj, $class;
30             }
31              
32             AUTOLOAD
33             {
34 1948944     1948944   12122964 my ($self, $exp) = @_;
35              
36 1948944         9147795 my ($caller, $sub) = $AUTOLOAD =~ /^(.+)::(.+)$/;
37              
38 1948944 100       6591345 if (substr($sub, 0, 2) eq '__') {
39 1938363         5387321 $sub =~ s/^__//;
40 26     26   218 no strict 'refs';
  26         74  
  26         2939  
41 1938363 100 66     6233354 if (defined $exp && length $exp) {
42 1927740         2868203 return ${$caller.'::'.$sub}{$exp};
  1927740         10212846  
43             }
44             else {
45 10623         17233 return \%{$caller.'::'.$sub};
  10623         142546  
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