line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EO::Pair; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
74
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
58
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1118
|
use EO::Array; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use base qw( EO::Array ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.96; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub at { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
if ($_[0] > 1) { |
14
|
|
|
|
|
|
|
throw EO::Error::InvalidParameters |
15
|
|
|
|
|
|
|
text => 'pairs cannot have indicies greater than 1'; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
$self->SUPER::at( @_ ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub do { |
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
my $code = shift; |
23
|
|
|
|
|
|
|
my $result; |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
local $_ = $self; |
26
|
|
|
|
|
|
|
$result = $code->( $self ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
return $result; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub key { |
32
|
|
|
|
|
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
return $self->at( 0, @_ ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub value { |
37
|
|
|
|
|
|
|
my $self = shift; |
38
|
|
|
|
|
|
|
return $self->at( 1, @_ ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
EO::Pair - simple pairs for EO. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use EO::Pair; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $pair = EO::Pair->new(); |
52
|
|
|
|
|
|
|
$pair->key( 'foo' ); |
53
|
|
|
|
|
|
|
$pair->value( 'bar' ); |
54
|
|
|
|
|
|
|
$pair->do( sub { print $_->key } ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
C provides a simple pair to EO. It is used by the EO::Hash class |
59
|
|
|
|
|
|
|
primarily. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
EO::Pair inherits from EO::Array and provides any constructors that EO::Array |
64
|
|
|
|
|
|
|
does. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item key( [KEYNAME] ) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The key method gets and sets the key name of the pair. This is the zeroth |
73
|
|
|
|
|
|
|
element in the array. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item value( [VALUE] ) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The value method gets and sets the value of the pair. This is the first\ |
78
|
|
|
|
|
|
|
element in the array. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item do( CODE ) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Runs the coderef passed by CODE. Sets $_ and the first argument to CODE as the |
83
|
|
|
|
|
|
|
pair object. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
James A. Duncan |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright 2004 Fotango Ltd. All Rights Reserved. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|