Skip to content

Commit

Permalink
Implemented RDF::Statement#reified.
Browse files Browse the repository at this point in the history
  • Loading branch information
artob committed Apr 9, 2010
1 parent 205614d commit 1a78a43
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/rdf/model/statement.rb
Expand Up @@ -237,5 +237,21 @@ def to_s
buffer.string
end
end

##
# Returns a graph containing this statement in reified form.
#
# @param [Hash{Symbol => Object}] options
# @return [RDF::Graph]
# @see http://www.w3.org/TR/rdf-primer/#reification
def reified(options = {})
RDF::Graph.new(options[:context]) do |graph|
subject = options[:subject] || RDF::Node.new(options[:id])
graph << [subject, RDF.type, RDF[:Statement]]
graph << [subject, RDF.subject, self.subject]
graph << [subject, RDF.predicate, self.predicate]
graph << [subject, RDF.object, self.object]
end
end
end
end

0 comments on commit 1a78a43

Please sign in to comment.