| 1 | package Template::Plugin::Lingua::EN::Numbers; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 6 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 6 | $VERSION = 0.02; | |||||||||
| 8 | |||||||||||
| 9 | 6 | ▶ | use base qw(Template::Plugin); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 6 | ▶ | use Template::Plugin; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 6 | ▶ | use Template::Stash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 6 | ▶ | use Lingua::EN::Numbers qw( num2en num2en_ordinal ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 6 | ▶ | use Lingua::EN::Numbers::Years qw( year2en ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 6 | ▶ | use Lingua::EN::Numbers::Ordinate qw( ordinate ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 6 | $Template::Stash::SCALAR_OPS->{'num2en'} = \&_num2en; | |||||||||
| 17 | 6 | $Template::Stash::SCALAR_OPS->{'num2en_ordinal'} = \&_num2en_ordinal; | |||||||||
| 18 | 6 | $Template::Stash::SCALAR_OPS->{'year2en'} = \&_year2en; | |||||||||
| 19 | 6 | $Template::Stash::SCALAR_OPS->{'ordinate'} = \&_ordinate; | |||||||||
| 20 | |||||||||||
| 21 | 8 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 8 | my ($class, $context, $options) = @_; | |||||||||
| 23 | |||||||||||
| 24 | # now define the filter and return the plugin | ||||||||||
| 25 | 8 | $context->define_filter('num2en', \&_num2en); | |||||||||
| 26 | 8 | $context->define_filter('num2en_ordinal', \&_num2en_ordinal); | |||||||||
| 27 | 8 | $context->define_filter('year2en', \&_year2en); | |||||||||
| 28 | 8 | $context->define_filter('ordinate', \&_ordinate); | |||||||||
| 29 | 8 | return bless {}, $class; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 3 | ▶ | sub _num2en { | ||||||||
|
Subroutine
_num2en: called CC=2 SCAR=7.2
| |||||||||||
| 33 | 3 | ▶ | my $options = ref $_[-1] eq 'HASH' ? pop : {}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 3 | return num2en(join('', @_)); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 3 | ▶ | sub _num2en_ordinal { | ||||||||
|
Subroutine
_num2en_ordinal: called CC=2 SCAR=7.2
| |||||||||||
| 38 | 3 | ▶ | my $options = ref $_[-1] eq 'HASH' ? pop : {}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 3 | return num2en_ordinal(join('', @_)); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 3 | ▶ | sub _year2en { | ||||||||
|
Subroutine
_year2en: called CC=2 SCAR=7.2
| |||||||||||
| 43 | 3 | ▶ | my $options = ref $_[-1] eq 'HASH' ? pop : {}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 3 | return year2en(join('', @_)); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 3 | ▶ | sub _ordinate { | ||||||||
|
Subroutine
_ordinate: called CC=2 SCAR=7.2
| |||||||||||
| 48 | 3 | ▶ | my $options = ref $_[-1] eq 'HASH' ? pop : {}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 3 | return ordinate(join('', @_)); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 6 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||