line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
50
|
|
|
50
|
|
647
|
use v5.14; |
|
50
|
|
|
|
|
156
|
|
2
|
50
|
|
|
50
|
|
248
|
use warnings; |
|
50
|
|
|
|
|
95
|
|
|
50
|
|
|
|
|
2243
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Attean::Result - SPARQL Result |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes Attean::Result version 0.033 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use v5.14; |
15
|
|
|
|
|
|
|
use Attean; |
16
|
|
|
|
|
|
|
my $result = Attean::Result->new(bindings => { name => $literal, homepage => $iri } ); |
17
|
|
|
|
|
|
|
my @vars = $result->variables; # ('name', 'homepage') |
18
|
|
|
|
|
|
|
my $term = $result->value('name'); # $term == $literal |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The Attean::Result class represents a SPARQL result (a set of bindings from |
23
|
|
|
|
|
|
|
variable names to L<term|Attean::API::Term>s). |
24
|
|
|
|
|
|
|
It conforms to the L<Attean::API::Result|Attean::API::Binding> role. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over 4 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Moo; |
33
|
50
|
|
|
50
|
|
289
|
use Types::Standard qw(HashRef ConsumerOf); |
|
50
|
|
|
|
|
126
|
|
|
50
|
|
|
|
|
279
|
|
34
|
50
|
|
|
50
|
|
15956
|
use Attean::API::Binding; |
|
50
|
|
|
|
|
133
|
|
|
50
|
|
|
|
|
465
|
|
35
|
50
|
|
|
50
|
|
30169
|
use namespace::clean; |
|
50
|
|
|
|
|
102
|
|
|
50
|
|
|
|
|
965
|
|
36
|
50
|
|
|
50
|
|
229
|
|
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
363
|
|
37
|
|
|
|
|
|
|
with 'Attean::API::Result'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item C<< bindings >> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns the HASH reference containing the variable bindings for this result. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has 'bindings' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::TermOrTriple']], default => sub { +{} }); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# sub BUILD { |
48
|
|
|
|
|
|
|
# my $self = shift; |
49
|
|
|
|
|
|
|
# my $args = shift; |
50
|
|
|
|
|
|
|
# use Data::Dumper; |
51
|
|
|
|
|
|
|
# my $b = $args->{bindings}; |
52
|
|
|
|
|
|
|
# my $keys = [keys %$b]; |
53
|
|
|
|
|
|
|
# if (scalar(@$keys) == 2) { |
54
|
|
|
|
|
|
|
# Carp::cluck 'NEW RESULT CONSTRUCTED with variables ' . Dumper($keys); |
55
|
|
|
|
|
|
|
# } |
56
|
|
|
|
|
|
|
# } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item C<< value( $name ) >> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns the term object bound to the C<< $name >>d variable, or undef if the |
61
|
|
|
|
|
|
|
name does not map to a term. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
my $k = shift; |
67
|
1075
|
|
|
1075
|
1
|
25547
|
return $self->bindings->{$k}; |
68
|
1075
|
|
|
|
|
1287
|
} |
69
|
1075
|
|
|
|
|
3263
|
|
70
|
|
|
|
|
|
|
=item C<< variables >> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns a list of the variable names that are bound to terms in this result |
73
|
|
|
|
|
|
|
object. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
return keys %{ $self->bindings }; |
79
|
|
|
|
|
|
|
} |
80
|
294
|
|
|
294
|
1
|
10287
|
|
81
|
294
|
|
|
|
|
325
|
=item C<< as_string >> |
|
294
|
|
|
|
|
1012
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns a string serialization of the variable bindings contained in the result. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
my @vars = $self->variables; |
89
|
|
|
|
|
|
|
my @strs = map { join('=', $_, $self->value($_)->ntriples_string) } sort $self->variables; |
90
|
|
|
|
|
|
|
return '{' . join(', ', @strs) . '}'; |
91
|
22
|
|
|
22
|
1
|
271
|
} |
92
|
22
|
|
|
|
|
51
|
} |
93
|
22
|
|
|
|
|
57
|
|
|
40
|
|
|
|
|
462
|
|
94
|
22
|
|
|
|
|
474
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 BUGS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
102
|
|
|
|
|
|
|
at L<https://github.com/kasei/attean/issues>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. |
115
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
116
|
|
|
|
|
|
|
the same terms as Perl itself. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |