| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 50 |  |  | 50 |  | 616 | use v5.14; | 
|  | 50 |  |  |  |  | 182 |  | 
| 2 | 50 |  |  | 50 |  | 265 | use warnings; | 
|  | 50 |  |  |  |  | 120 |  | 
|  | 50 |  |  |  |  | 2237 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | =head1 NAME | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | Attean::Result - SPARQL Result | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 VERSION | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | This document describes Attean::Result version 0.032 | 
| 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 |  | 285 | use Types::Standard qw(HashRef ConsumerOf); | 
|  | 50 |  |  |  |  | 107 |  | 
|  | 50 |  |  |  |  | 318 |  | 
| 34 | 50 |  |  | 50 |  | 15897 | use Attean::API::Binding; | 
|  | 50 |  |  |  |  | 141 |  | 
|  | 50 |  |  |  |  | 421 |  | 
| 35 | 50 |  |  | 50 |  | 30951 | use namespace::clean; | 
|  | 50 |  |  |  |  | 109 |  | 
|  | 50 |  |  |  |  | 1047 |  | 
| 36 | 50 |  |  | 50 |  | 237 |  | 
|  | 50 |  |  |  |  | 102 |  | 
|  | 50 |  |  |  |  | 378 |  | 
| 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 | 1081 |  |  | 1081 | 1 | 23958 | return $self->bindings->{$k}; | 
| 68 | 1081 |  |  |  |  | 1158 | } | 
| 69 | 1081 |  |  |  |  | 3524 |  | 
| 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 | 297 |  |  | 297 | 1 | 12396 |  | 
| 81 | 297 |  |  |  |  | 343 | =item C<< as_string >> | 
|  | 297 |  |  |  |  | 959 |  | 
| 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 | 23 |  |  | 23 | 1 | 200 | } | 
| 92 | 23 |  |  |  |  | 42 | } | 
| 93 | 23 |  |  |  |  | 48 |  | 
|  | 43 |  |  |  |  | 438 |  | 
| 94 | 23 |  |  |  |  | 435 | 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 |