module RDF::JSON::Extensions

RDF/JSON extensions for [RDF.rb](github.com/ruby-rdf/rdf) core classes and mixins.

Classes are extended with two new instance methods:

@example Serializing blank nodes into RDF/JSON format

RDF::Node.new(id).to_rdf_json.to_json

@example Serializing URI references into RDF/JSON format

RDF::URI.new("https://rubygems.org/gems/rdf/").to_rdf_json.to_json

@example Serializing plain literals into RDF/JSON format

RDF::Literal.new("Hello, world!").to_rdf_json.to_json

@example Serializing language-tagged literals into RDF/JSON format

RDF::Literal.new("Hello, world!", :language => 'en-US').to_rdf_json.to_json

@example Serializing datatyped literals into RDF/JSON format

RDF::Literal.new(3.1415).to_rdf_json.to_json
RDF::Literal.new('true', :datatype => RDF::XSD.boolean).to_rdf_json.to_json

@example Serializing statements into RDF/JSON format

RDF::Statement.new(s, p, o).to_rdf_json.to_json

@example Serializing enumerables into RDF/JSON format

[RDF::Statement.new(s, p, o)].extend(RDF::Enumerable).to_rdf_json.to_json

Public Class Methods

install!() click to toggle source

@private

# File lib/rdf/json/extensions.rb, line 36
def self.install!
  self.constants.each do |klass|
    RDF.const_get(klass).send(:include, self.const_get(klass))
  end
end