Object/String.pm

filter: Statementstmt 100% 31 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 100% 3 / 3 totaltotal 100% 48 / 48 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Object/DigitString.pm ↑ Summary
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings qw(FATAL closed internal debugging pack malloc portable
Subroutine BEGIN: called CC=1 SCAR=0.0
10 prototype inplace io pipe unpack deprecated glob digit
11 1 printf reserved taint closure semicolon);
12 1 ▶no warnings qw(exec newline unopened);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use base qw(Range::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # Overload definitions
19  
20 1 ▶use overload q{""} => 'stringify',
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 fallback => 1;
22  
23 ### PUBLIC INSTANCE METHOD ###
24 #
25 # Returns regex for matching strings -- any strings.
26 #
27  
28 52 ▶sub pattern {
Subroutine pattern: called CC=1 SCAR=0.0
Pod documented
29 52 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 ▶sub separator { qr/ [\r\n\t] /xms }
Subroutine separator: called CC=1 SCAR=0.0
Pod documented
39  
40 ### PUBLIC INSTANCE METHOD ###
41 #
42 # Returns default range delimiter; Strings use newline ("\n").
43 #
44  
45 24 ▶sub delimiter { "\n" }
Subroutine delimiter: called CC=1 SCAR=0.0
Pod documented
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 ▶sub _list_separator { "\n" }
Subroutine _list_separator: called CC=1 SCAR=0.0
56  
57 ### PRIVATE INSTANCE METHOD ###
58 #
59 # Expands a list of items using Perl range operator.
60 # Does nothing for Strings.
61 #
62  
63 106 ▶sub _explode_range {
Subroutine _explode_range: called CC=1 SCAR=0.0
64 106 my ($self, $string) = @_;
65  
66 106 return ($string);
67 }
68  
69 ### PRIVATE INSTANCE METHOD ###
70 #
71 # Tests if two values are equal.
72 #
73  
74 362 ▶sub _equal_value {
Subroutine _equal_value: called CC=1 SCAR=0.0
75 362 my ($self, $first, $last) = @_;
76  
77 362 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 ▶sub _next_in_range { return; }
Subroutine _next_in_range: called CC=1 SCAR=0.0
87  
88 1 1;
89  
90 __END__
« Object/DigitString.pm ↑ Summary