module RDF::JSON::Extensions::Enumerable
RDF/JSON extensions for ‘RDF::Enumerable`.
Public Instance Methods
to_rdf_json()
click to toggle source
Returns the RDF/JSON representation of this object.
@return [Hash]
# File lib/rdf/json/extensions.rb, line 104 def to_rdf_json json = {} each_statement do |statement| s = statement.subject.to_s p = statement.predicate.to_s o = statement.object.is_a?(RDF::Value) ? statement.object : RDF::Literal.new(statement.object) json[s] ||= {} json[s][p] ||= [] json[s][p] << o.to_rdf_json end json end