File Coverage

blib/lib/Range/Object/String.pm
Criterion Covered Total %
statement 30 30 100.0
branch n/a
condition n/a
subroutine 14 14 100.0
pod 3 3 100.0
total 47 47 100.0


line stmt bran cond sub pod time code
1             package Range::Object::String;
2              
3             # This is basically what common::sense does, but without the pragma itself
4             # to remain compatible with Perls older than 5.8
5              
6 1     1   48398 use strict;
  1         11  
  1         25  
7              
8 1     1   5 no warnings;
  1         2  
  1         41  
9 1         61 use warnings qw(FATAL closed internal debugging pack malloc portable
10             prototype inplace io pipe unpack deprecated glob digit
11 1     1   4 printf reserved taint closure semicolon);
  1         2  
12 1     1   4 no warnings qw(exec newline unopened);
  1         2  
  1         25  
13              
14 1     1   4 use Carp;
  1         2  
  1         48  
15              
16 1     1   4 use base qw(Range::Object);
  1         2  
  1         313  
17              
18             # Overload definitions
19              
20 1         5 use overload q{""} => 'stringify',
21 1     1   1137 fallback => 1;
  1         815  
22              
23             ### PUBLIC INSTANCE METHOD ###
24             #
25             # Returns regex for matching strings -- any strings.
26             #
27              
28             sub pattern {
29 52     52 1 174 return qr/\A .* \z/xms
30             }
31              
32             ### PUBLIC INSTANCE METHOD ###
33             #
34             # Returns regex that is used to separate items in a range list.
35             # Default for Strings are \r, \n or \t.
36             #
37              
38 52     52 1 119 sub separator { qr/ [\r\n\t] /xms }
39              
40             ### PUBLIC INSTANCE METHOD ###
41             #
42             # Returns default range delimiter; Strings use newline ("\n").
43             #
44              
45 24     24 1 57 sub delimiter { "\n" }
46              
47             ############## PRIVATE METHODS BELOW ##############
48              
49             ### PRIVATE INSTANCE METHOD ###
50             #
51             # Returns default list separator for use with stringify() and
52             # stringify_collapsed()
53             #
54              
55 18     18   64 sub _list_separator { "\n" }
56              
57             ### PRIVATE INSTANCE METHOD ###
58             #
59             # Expands a list of items using Perl range operator.
60             # Does nothing for Strings.
61             #
62              
63             sub _explode_range {
64 106     106   168 my ($self, $string) = @_;
65              
66 106         238 return ($string);
67             }
68              
69             ### PRIVATE INSTANCE METHOD ###
70             #
71             # Tests if two values are equal.
72             #
73              
74             sub _equal_value {
75 362     362   546 my ($self, $first, $last) = @_;
76              
77 362         835 return !!($first eq $last);
78             }
79              
80             ### PRIVATE INSTANCE METHOD ###
81             #
82             # Tests if two values are consequent. Since string ranges are actually
83             # disjointed collections, this method does nothing.
84             #
85              
86 24     24   48 sub _next_in_range { return; }
87              
88             1;
89              
90             __END__