| 1 | # $Id$ | ||||||||||
| 2 | # | ||||||||||
| 3 | # This is free software, you may use it and distribute it under the same terms as | ||||||||||
| 4 | # Perl itself. | ||||||||||
| 5 | # | ||||||||||
| 6 | # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas | ||||||||||
| 7 | # | ||||||||||
| 8 | # | ||||||||||
| 9 | |||||||||||
| 10 | package XML::LibXML::Number; | ||||||||||
| 11 | 77 | ▶ | use XML::LibXML::Boolean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 77 | ▶ | use XML::LibXML::Literal; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 77 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 77 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 77 | our $VERSION = "2.0213"; # VERSION TEMPLATE: DO NOT CHANGE | |||||||||
| 17 | |||||||||||
| 18 | use overload | ||||||||||
| 19 | 77 | ▶ | '""' => \&value, | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | '0+' => \&value, | ||||||||||
| 21 | 77 | '<=>' => \&cmp; | |||||||||
| 22 | |||||||||||
| 23 | 27 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 24 | 27 | my $class = shift; | |||||||||
| 25 | 27 | my $number = shift; | |||||||||
| 26 | 27 | ▶ | if ($number !~ /^\s*(-\s*)?(\d+(\.\d*)?|\.\d+)\s*$/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | $number = undef; | |||||||||
| 28 | } | ||||||||||
| 29 | else { | ||||||||||
| 30 | 27 | $number =~ s/\s+//g; | |||||||||
| 31 | } | ||||||||||
| 32 | 27 | bless \$number, $class; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 22 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||
| 36 | 22 | my $self = shift; | |||||||||
| 37 | 22 | ▶ | defined $$self ? $$self : 'NaN'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub as_xml { | ||||||||
|
Subroutine
as_xml: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 41 | 0 | my $self = shift; | |||||||||
| 42 | 0 | ▶ | return "<Number>" . (defined($$self) ? $$self : 'NaN') . "</Number>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 3 | ▶ | sub value { | ||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 46 | 3 | my $self = shift; | |||||||||
| 47 | 3 | $$self; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 1 | ▶ | sub cmp { | ||||||||
|
Subroutine
cmp: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||
| 51 | 1 | my $self = shift; | |||||||||
| 52 | 1 | my ($other, $swap) = @_; | |||||||||
| 53 | 1 | ▶ | if ($swap) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | return $other <=> $$self; | |||||||||
| 55 | } | ||||||||||
| 56 | 1 | return $$self <=> $other; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | sub evaluate { | ||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 60 | 0 | my $self = shift; | |||||||||
| 61 | 0 | $self; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub to_boolean { | ||||||||
|
Subroutine
to_boolean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 65 | 0 | my $self = shift; | |||||||||
| 66 | 0 | ▶ | return $$self ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 22 | ▶ | sub to_literal { XML::LibXML::Literal->new($_[0]->as_string); } | ||||||||
|
Subroutine
to_literal: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 70 | 0 | ▶ | sub to_number { $_[0]; } | ||||||||
|
Subroutine
to_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | sub string_value { return $_[0]->value } | ||||||||
|
Subroutine
string_value: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 73 | |||||||||||
| 74 | 77 | 1; | |||||||||
| 75 | __END__ | ||||||||||