File Coverage

blib/lib/RDF/Trine/Node/Nil.pm
Criterion Covered Total %
statement 41 47 87.2
branch 5 6 83.3
condition 2 3 66.6
subroutine 14 18 77.7
pod 7 7 100.0
total 69 81 85.1


line stmt bran cond sub pod time code
1             # RDF::Trine::Node::Nil
2             # -----------------------------------------------------------------------------
3              
4             =head1 NAME
5              
6             RDF::Trine::Node::Nil - RDF Node class for the nil node
7              
8             =head1 VERSION
9              
10             This document describes RDF::Trine::Node::Nil version 1.018
11              
12             =cut
13              
14             package RDF::Trine::Node::Nil;
15              
16 68     68   380 use strict;
  68         135  
  68         1539  
17 68     68   289 use warnings;
  68         128  
  68         1400  
18 68     68   279 no warnings 'redefine';
  68         134  
  68         1938  
19 68     68   351 use base qw(RDF::Trine::Node);
  68         558  
  68         4384  
20              
21 68     68   748 use Data::Dumper;
  68         210  
  68         2762  
22 68     68   380 use Scalar::Util qw(blessed refaddr);
  68         146  
  68         2836  
23 68     68   346 use Carp qw(carp croak confess);
  68         138  
  68         3969  
24              
25             ######################################################################
26              
27             my $NIL_NODE;
28             our ($VERSION);
29             BEGIN {
30 68     68   2593 $VERSION = '1.018';
31             }
32              
33             ######################################################################
34              
35 5690     5690   11828 use overload '""' => sub { $_[0]->sse },
36 68     68   365 ;
  68         146  
  68         524  
37              
38             =head1 METHODS
39              
40             Beyond the methods documented below, this class inherits methods from the
41             L<RDF::Trine::Node> class.
42              
43             =over 4
44              
45             =cut
46              
47             =item C<< new () >>
48              
49             Returns the nil-valued node.
50              
51             =cut
52              
53             sub new {
54 4330     4330 1 7939 my $class = shift;
55 4330 100       12818 if (blessed($NIL_NODE)) {
56 4292         11069 return $NIL_NODE;
57             } else {
58 38         115 $NIL_NODE = bless({}, $class);
59 38         129 return $NIL_NODE;
60             }
61             }
62              
63             =item C<< is_nil >>
64              
65             Returns true if this object is the nil-valued node.
66              
67             =cut
68              
69             sub is_nil {
70 102     102 1 198 my $self = shift;
71 102         781 return (refaddr($self) == refaddr($NIL_NODE));
72             }
73              
74             =item C<< sse >>
75              
76             Returns the SSE string for this nil node.
77              
78             =cut
79              
80             sub sse {
81 20983     20983 1 30651 my $self = shift;
82 20983         59887 return '(nil)';
83             }
84              
85             =item C<< as_ntriples >>
86              
87             Returns the N-Triples serialization of the nil node's IRI
88             <tag:gwilliams@cpan.org,2010-01-01:RT:NIL>.
89              
90             =cut
91              
92             sub as_ntriples {
93 0     0 1 0 my $self = shift;
94 0         0 return sprintf('<%s>', &RDF::Trine::NIL_GRAPH());
95             }
96              
97             =item C<< type >>
98              
99             Returns the type string of this node.
100              
101             =cut
102              
103             sub type {
104 0     0 1 0 return 'NIL';
105             }
106              
107             =item C<< value >>
108              
109             Returns the empty string.
110              
111             =cut
112              
113             sub value {
114 0     0 1 0 my $self = shift;
115 0         0 return '';
116             }
117              
118             =item C<< equal ( $node ) >>
119              
120             Returns true if the two nodes are equal, false otherwise.
121              
122             =cut
123              
124             sub equal {
125 4     4 1 491 my $self = shift;
126 4         6 my $node = shift;
127 4 50       21 return 0 unless (blessed($node));
128 4 100 66     43 if ($self->isa('RDF::Trine::Node::Nil') and $node->isa('RDF::Trine::Node::Nil')) {
129 2         10 return 1;
130             } else {
131 2         9 return 0;
132             }
133             }
134              
135             # called to compare two nodes of the same type
136             sub _compare {
137 0     0     return 0;
138             }
139              
140             1;
141              
142             __END__
143              
144             =back
145              
146             =head1 BUGS
147              
148             Please report any bugs or feature requests to through the GitHub web interface
149             at L<https://github.com/kasei/perlrdf/issues>.
150              
151             =head1 AUTHOR
152              
153             Gregory Todd Williams C<< <gwilliams@cpan.org> >>
154              
155             =head1 COPYRIGHT
156              
157             Copyright (c) 2006-2012 Gregory Todd Williams. This
158             program is free software; you can redistribute it and/or modify it under
159             the same terms as Perl itself.
160              
161             =cut