| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | Text::Same::Range | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | A class representing a range of integers | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | my $range = new Text::Same::Range($start, $end); | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 METHODS | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | See below. Methods private to this module are prefixed by an | ||||||||||||||||||||||||||||
| 16 | underscore. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | package Text::Same::Range; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 4 | $VERSION = '0.07'; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head2 new | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Title : new | ||||||||||||||||||||||||||||
| 32 | Usage : $range = new Text::Same::Range($start, $end) | ||||||||||||||||||||||||||||
| 33 | Function: Creates a new Range object with the given start and end | ||||||||||||||||||||||||||||
| 34 | Returns : A Text::Same::Range object | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub new | ||||||||||||||||||||||||||||
| 39 | 45 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 45 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 45 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 45 | ▶ | if (scalar(@_) != 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | die "Range constructor needs 2 arguments\n"; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 45 | ▶ | if (!defined $_[0] || !defined $_[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and defined $_[1]
MC/DC0%0/2
defined $_[0] and defined $_[1]
defined $_[0]
defined $_[1]
Truth table33%1/3
A and B
A= defined $_[0]B= defined $_[1]
| |||||||||||||||||||||||||||||
| 48 | 0 | croak "undefined value passed to Range->new\n"; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 45 | return bless [@_], $class; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head2 start | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | Title : start | ||||||||||||||||||||||||||||
| 57 | Usage : $start = $range->start | ||||||||||||||||||||||||||||
| 58 | Function: Returns the start position that was passed to new() | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub start | ||||||||||||||||||||||||||||
| 63 | 30 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 30 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | 30 | return $self->[0]; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head2 end | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Title : end | ||||||||||||||||||||||||||||
| 71 | Usage : $end = $range->end | ||||||||||||||||||||||||||||
| 72 | Function: Returns the end position that was passed to new() | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | sub end | ||||||||||||||||||||||||||||
| 77 | 30 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
end: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 30 | my $self = shift; | |||||||||||||||||||||||||||
| 79 | 30 | return $self->[1]; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head2 as_string | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Title : as_string | ||||||||||||||||||||||||||||
| 85 | Usage : my $str = $range->as_string | ||||||||||||||||||||||||||||
| 86 | Function: return a string representation of this Range | ||||||||||||||||||||||||||||
| 87 | Args : none | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =cut | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub as_string | ||||||||||||||||||||||||||||
| 92 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | 0 | return $self->[0] . ".." . $self->[1]; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | Kim Rutherford <kmr+same@xenu.org.uk> | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | Copyright 2005,2006 Kim Rutherford. All rights reserved. | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 106 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 DISCLAIMER | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | This module is provided "as is" without warranty of any kind. It | ||||||||||||||||||||||||||||
| 111 | may redistributed under the same conditions as Perl itself. | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 4 | 1; | |||||||||||||||||||||||||||