Tagged/Extent.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 8 / 8 totaltotal 100% 35 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
string
1.0
CRAP 1.0
« Tagged.pm ↑ Summary
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2008-2022 -- leonerd@leonerd.org.uk
5  
6 package String::Tagged::Extent 0.24;
7  
8 21 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 C<String::Tagged::Extent> - represents a range within a C<String::Tagged>
14  
15 =head1 DESCRIPTION
16  
17 These objects represent a range of characters within the containing
18 L<String::Tagged> object. The range they represent is fixed at the time of
19 creation. If the containing string is modified by a call to C<set_substr>
20 then the effect on the extent object is not defined. These objects should be
21 considered as relatively short-lived - used briefly for the purpose of
22 querying the result of an operation, then discarded soon after.
23  
24 =cut
25  
26 =head1 METHODS
27  
28 =cut
29  
30 =head2 string
31  
32 $extent->string;
33  
34 Returns the containing L<String::Tagged> object.
35  
36 =cut
37  
38 sub string
39 33 ▶{
Subroutine string: called CC=1 SCAR=0.0
Pod documented
40 33 shift->[0]
41 }
42  
43 =head2 start
44  
45 $extent->start;
46  
47 Returns the start index of the extent. This is the index of the first
48 character within the extent.
49  
50 =cut
51  
52 sub start
53 378 ▶{
Subroutine start: called CC=1 SCAR=0.0
Pod documented
54 378 shift->[1]
55 }
56  
57 =head2 end
58  
59 $extent->end;
60  
61 Returns the end index of the extent. This is the index of the first character
62 beyond the end of the extent.
63  
64 =cut
65  
66 sub end
67 197 ▶{
Subroutine end: called CC=1 SCAR=0.0
Pod documented
68 197 shift->[2]
69 }
70  
71 =head2 anchor_before
72  
73 $extent->anchor_before;
74  
75 True if this extent begins "before" the start of the string. Only certain
76 methods return extents with this flag defined.
77  
78 =cut
79  
80 sub anchor_before
81 13 ▶{
Subroutine anchor_before: called CC=1 SCAR=0.0
Pod documented
82 13 shift->[3] & String::Tagged::FLAG_ANCHOR_BEFORE;
83 }
84  
85 =head2 anchor_after
86  
87 $extent->anchor_after;
88  
89 True if this extent ends "after" the end of the string. Only certain methods
90 return extents with this flag defined.
91  
92 =cut
93  
94 sub anchor_after
95 26 ▶{
Subroutine anchor_after: called CC=1 SCAR=0.0
Pod documented
96 26 shift->[3] & String::Tagged::FLAG_ANCHOR_AFTER;
97 }
98  
99 =head2 length
100  
101 $extent->length;
102  
103 Returns the number of characters within the extent.
104  
105 =cut
106  
107 sub length
108 179 ▶{
Subroutine length: called CC=1 SCAR=0.0
Pod documented
109 179 my $self = shift;
110 179 $self->end - $self->start;
111 }
112  
113 =head2 substr
114  
115 $extent->substr;
116  
117 Returns the substring contained by the extent, as a L<String::Tagged>
118 complete with all the relevant tag values.
119  
120 =cut
121  
122 sub substr
123 8 ▶{
Subroutine substr: called CC=1 SCAR=0.0
Pod documented
124 8 my $self = shift;
125 8 $self->string->substr( $self->start, $self->length );
126 }
127  
128 =head2 plain_substr
129  
130 $extent->plain_substr;
131  
132 Returns the substring of the underlying plain string buffer contained by the
133 extent, as a plain Perl string.
134  
135 =cut
136  
137 sub plain_substr
138 22 ▶{
Subroutine plain_substr: called CC=1 SCAR=0.0
Pod documented
139 22 my $self = shift;
140 22 $self->string->plain_substr( $self->start, $self->length );
141 }
142  
143 =head1 AUTHOR
144  
145 Paul Evans <leonerd@leonerd.org.uk>
146  
147 =cut
148  
149 21 0x55AA;
« Tagged.pm ↑ Summary