Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion lib/rdf/model/graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module RDF
#
# @example Loading graph data from a URL
# require 'rdf/rdfxml' # for RDF/XML support
#
#
# graph = RDF::Graph.load("http://www.bbc.co.uk/programmes/b0081dq5.rdf")
#
# @example Accessing a specific named graph within a {RDF::Repository}
Expand Down Expand Up @@ -250,6 +250,36 @@ def statement?(*args)
end
alias_method :has_statement?, :statement?

##
# Returns `true` if `self` contains the given RDF subject term.
#
# @param [RDF::Resource] value
# @return [Boolean]
def subject? value
[email protected]({ subject: value, graph_name: graph_name || false }).empty?
end
alias_method :has_subject?, :subject?

##
# Returns `true` if `self` contains the given RDF predicate term.
#
# @param [RDF::URI] value
# @return [Boolean]
def predicate? value
[email protected]({ predicate: value, graph_name: graph_name || false }).empty?
end
alias_method :has_predicate?, :predicate?

##
# Returns `true` if `self` contains the given RDF object term.
#
# @param [RDF::Term] value
# @return [Boolean]
def object? value
[email protected]({ object: value, graph_name: graph_name || false }).empty?
end
alias_method :has_object?, :object?

##
# Enumerates each RDF statement in this graph.
#
Expand Down