File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,11 +138,22 @@ def load!(*args)
138138 end
139139
140140 ##
141- # Returns `true` to indicate that this is a graph.
141+ # @overload graph?
142+ # Returns `true` to indicate that this is a graph.
142143 #
143- # @return [Boolean]
144- def graph?
145- true
144+ # @return [Boolean]
145+ # @overload graph?(name)
146+ # Returns `true` if `self` contains the given RDF graph_name.
147+ #
148+ # @param [RDF::Resource, false] graph_name
149+ # Use value `false` to query for the default graph_name
150+ # @return [Boolean]
151+ def graph? ( *args )
152+ case args . length
153+ when 0 then true
154+ when 1 then graph_name == args . first
155+ else raise ArgumentError ( "wrong number of arguments (given #{ args . length } , expected 0 or 1)" )
156+ end
146157 end
147158
148159 ##
Original file line number Diff line number Diff line change @@ -215,9 +215,22 @@ def complete?
215215 end
216216
217217 ##
218- # @return [Boolean]
219- def graph?
220- !!graph_name
218+ # @overload graph?
219+ # Returns `true` if the statement has a graph name.
220+ #
221+ # @return [Boolean]
222+ # @overload graph?(name)
223+ # Returns `true` if `self` contains the given RDF graph_name.
224+ #
225+ # @param [RDF::Resource, false] graph_name
226+ # Use value `false` to query for the default graph_name
227+ # @return [Boolean]
228+ def graph? ( *args )
229+ case args . length
230+ when 0 then !!graph_name
231+ when 1 then graph_name == args . first
232+ else raise ArgumentError ( "wrong number of arguments (given #{ args . length } , expected 0 or 1)" )
233+ end
221234 end
222235 alias_method :name? , :graph?
223236 alias_method :has_graph? , :graph?
Original file line number Diff line number Diff line change @@ -29,11 +29,22 @@ module RDF
2929 # @see RDF::Statement
3030 module Value
3131 ##
32- # Returns `true` if `self` is a {RDF::Graph}.
32+ # @overload graph?
33+ # Returns `true` if `self` is a {RDF::Graph}.
3334 #
34- # @return [Boolean]
35- def graph?
35+ # @return [Boolean]
36+ # @overload graph?(name)
37+ # Returns `true` if `self` contains the given RDF graph_name.
38+ #
39+ # @param [RDF::Resource, false] graph_name
40+ # Use value `false` to query for the default graph_name
41+ # @return [Boolean]
42+ def graph? ( *args )
3643 false
44+ case args . length
45+ when 0 , 1 then false
46+ else raise ArgumentError ( "wrong number of arguments (given #{ args . length } , expected 0 or 1)" )
47+ end
3748 end
3849
3950 ##
You can’t perform that action at this time.
0 commit comments