File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ module RDF
2020 #
2121 # @example Loading graph data from a URL
2222 # require 'rdf/rdfxml' # for RDF/XML support
23- #
23+ #
2424 # graph = RDF::Graph.load("http://www.bbc.co.uk/programmes/b0081dq5.rdf")
2525 #
2626 # @example Accessing a specific named graph within a {RDF::Repository}
@@ -250,6 +250,36 @@ def statement?(*args)
250250 end
251251 alias_method :has_statement? , :statement?
252252
253+ ##
254+ # Returns `true` if `self` contains the given RDF subject term.
255+ #
256+ # @param [RDF::Resource] value
257+ # @return [Boolean]
258+ def subject? value
259+ !@data . query ( { subject : value , graph_name : graph_name || false } ) . empty?
260+ end
261+ alias_method :has_subject? , :subject?
262+
263+ ##
264+ # Returns `true` if `self` contains the given RDF predicate term.
265+ #
266+ # @param [RDF::URI] value
267+ # @return [Boolean]
268+ def predicate? value
269+ !@data . query ( { predicate : value , graph_name : graph_name || false } ) . empty?
270+ end
271+ alias_method :has_predicate? , :predicate?
272+
273+ ##
274+ # Returns `true` if `self` contains the given RDF object term.
275+ #
276+ # @param [RDF::Term] value
277+ # @return [Boolean]
278+ def object? value
279+ !@data . query ( { object : value , graph_name : graph_name || false } ) . empty?
280+ end
281+ alias_method :has_object? , :object?
282+
253283 ##
254284 # Enumerates each RDF statement in this graph.
255285 #
You can’t perform that action at this time.
0 commit comments