Method: JSON::LD::API.fromRDF

Defined in:
lib/json/ld/api.rb

.fromRDF(input, callback = nil, options = {}) {|jsonld| ... } ⇒ Array<Hash>

Take an ordered list of RDF::Statements and turn them into a JSON-LD document.

The resulting Array is returned via the provided callback.

Note that for Ruby, if the callback is not provided and a block is given, it will be yielded

Parameters:

  • input (Array<RDF::Statement>)
  • callback (Proc) (defaults to: nil)

    (&block) Alternative to using block, with same parameteres.

  • options (Hash{Symbol => Object}) (defaults to: {})

    See options in #initialize

Yields:

  • jsonld

Yield Parameters:

  • jsonld (Hash)

    The JSON-LD document in expanded form

Returns:

  • (Array<Hash>)

    The JSON-LD document in expanded form



404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/json/ld/api.rb', line 404

def self.fromRDF(input, callback = nil, options = {}, &block)
  options = {:useNativeTypes => true}.merge(options)
  result = nil

  API.new(nil, nil, options) do |api|
    result = api.from_statements(input)
  end

  callback ||= block if block_given?
  callback.call(result) if callback
  result
end