| 1 | package XML::XPath::Number; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | $VERSION = '1.26'; | |||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use XML::XPath::Boolean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use XML::XPath::Literal; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | use overload | ||||||||||
| 10 | 1 | '""' => \&value, | |||||||||
| 11 | '0+' => \&value, | ||||||||||
| 12 | 1 | ▶ | '<=>' => \&cmp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | sub new { | ||||||||||
| 15 | 0 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 16 | 0 | my $number = shift; | |||||||||
| 17 | 0 | ▶ | if ($number !~ /^\s*[+-]?(\d+(\.\d*)?|\.\d+)\s*$/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | $number = undef; | |||||||||
| 19 | } | ||||||||||
| 20 | else { | ||||||||||
| 21 | 0 | $number =~ s/^\s*(.*)\s*$/$1/; | |||||||||
| 22 | } | ||||||||||
| 23 | 0 | bless \$number, $class; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | sub as_string { | ||||||||||
| 27 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_string: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 28 | 0 | ▶ | defined $$self ? $$self : 'NaN'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | sub as_xml { | ||||||||||
| 32 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_xml: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 33 | 0 | ▶ | return "<Number>" . (defined($$self) ? $$self : 'NaN') . "</Number>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | sub value { | ||||||||||
| 37 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 38 | 0 | $$self; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | sub cmp { | ||||||||||
| 42 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
cmp: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 43 | 0 | my ($other, $swap) = @_; | |||||||||
| 44 | 0 | ▶ | if ($swap) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | return $other <=> $$self; | |||||||||
| 46 | } | ||||||||||
| 47 | 0 | return $$self <=> $other; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | sub evaluate { | ||||||||||
| 51 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 52 | 0 | $self; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub to_boolean { | ||||||||||
| 56 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
to_boolean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 57 | 0 | ▶ | return $$self ? XML::XPath::Boolean->True : XML::XPath::Boolean->False; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub to_literal { XML::XPath::Literal->new($_[0]->as_string); } | ||||||||
|
Subroutine
to_literal: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 61 | 0 | ▶ | sub to_number { $_[0]; } | ||||||||
|
Subroutine
to_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub string_value { return $_[0]->value } | ||||||||
|
Subroutine
string_value: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 64 | |||||||||||
| 65 | 1 | 1; | |||||||||
| 66 | __END__ | ||||||||||