| 1 | package Farly::Value::Integer; | ||||||||||
| 2 | |||||||||||
| 3 | 17 | ▶ | use 5.008008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 17 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 17 | our $VERSION = '0.26'; | |||||||||
| 9 | |||||||||||
| 10 | 122 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 11 | 122 | my ( $class, $number ) = @_; | |||||||||
| 12 | |||||||||||
| 13 | 122 | ▶ | confess "integer required" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | unless defined($number); | ||||||||||
| 15 | |||||||||||
| 16 | 121 | $number =~ s/^\s+|\s+$//g; | |||||||||
| 17 | |||||||||||
| 18 | 121 | ▶ | confess "not an integer" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | unless ( $number =~ /^\d+$/ ); | ||||||||||
| 20 | |||||||||||
| 21 | 120 | return bless( \$number, $class ); | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 430 | ▶ | sub number { return ${ $_[0] } } | ||||||||
|
Subroutine
number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 25 | |||||||||||
| 26 | 121 | ▶ | sub as_string { return ${ $_[0] } } | ||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 27 | |||||||||||
| 28 | 189 | ▶ | sub equals { | ||||||||
|
Subroutine
equals: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 189 | my ( $self, $other ) = @_; | |||||||||
| 30 | |||||||||||
| 31 | 189 | ▶ | if ( $other->isa('Farly::Value::Integer') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 135 | return $self->number() == $other->number(); | |||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 1 | ▶ | sub contains { | ||||||||
|
Subroutine
contains: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 37 | 1 | my ( $self, $other ) = @_; | |||||||||
| 38 | 1 | return $self->equals($other); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 2 | ▶ | sub intersects { | ||||||||
|
Subroutine
intersects: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 42 | 2 | my ( $self, $other ) = @_; | |||||||||
| 43 | 2 | return $self->equals($other); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 71 | ▶ | sub compare { | ||||||||
|
Subroutine
compare: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 47 | 71 | my ( $self, $other ) = @_; | |||||||||
| 48 | |||||||||||
| 49 | 71 | ▶ | if ( $other->isa('Farly::Value::Integer') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 71 | return $self->number() <=> $other->number(); | |||||||||
| 51 | } | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 2 | ▶ | sub gt { | ||||||||
|
Subroutine
gt: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 55 | 2 | my ( $self, $other ) = @_; | |||||||||
| 56 | |||||||||||
| 57 | 2 | ▶ | if ( $other->isa('Farly::Value::Integer') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 2 | return $self->number() > $other->number(); | |||||||||
| 59 | } | ||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 1 | ▶ | sub lt { | ||||||||
|
Subroutine
lt: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 63 | 1 | my ( $self, $other ) = @_; | |||||||||
| 64 | |||||||||||
| 65 | 1 | ▶ | if ( $other->isa('Farly::Value::Integer') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 1 | return $self->number() < $other->number(); | |||||||||
| 67 | } | ||||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 1 | ▶ | sub incr { | ||||||||
|
Subroutine
incr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 71 | 1 | ${ $_[0] }++; | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 1 | ▶ | sub decr { | ||||||||
|
Subroutine
decr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 75 | 1 | ${ $_[0] }--; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 17 | 1; | |||||||||
| 79 | __END__ | ||||||||||