module ROF::Translators::JsonldToRof::StatementHandler

Responsible for parsing an RDF statement and adding to the accumulator.

@see ROF::Translators::JsonldToRof::StatementHandler.call

Public Class Methods

call(statement, accumulator) click to toggle source

@api public

Parse the RDF statement and add it's contents to the accumulator

@example

Given the following 4 RDF N-Triples (subject, predicate, object). The first two, with subject "_:b0" represent blank nodes.
The last one with subject "<https://curate.nd.edu/show/zk51vd69n1r>" has an object that points to the "_:b0" blank node.
  _:b0 <http://purl.org/dc/terms/contributor> "David R.Hyde" .
  _:b0 <http://www.ndltd.org/standards/metadata/etdms/1.1/role> "Research Director" .
  <https://curate.nd.edu/show/zk51vd69n1r> <http://purl.org/dc/terms/contributor> _:b0 .
  <https://curate.nd.edu/show/zk51vd69n1r> <http://projecthydra.org/ns/relations#hasEditorGroup> <https://curate.nd.edu/show/q524jm23g92> .
For the first two N-Triples you would get a BlankNodeHandler; For the last two, you would get a UriSubjectHandler

@note It is assumed that all blank nodes (e.g. RDF::Node) will be processed before you process any RDF::URI nodes.

@param [RDF::Statement] statement - the RDF statement that we will parse and add to the appropriate spot in the accumulator @param [ROF::Translators::JsonldToRof::Accumulator] accumulator - a data accumulator that will be changed in place @return [ROF::Translators::JsonldToRof::Accumulator] the given accumulator @raise [ROF::Translators::JsonldToRof::UnhandledRdfSubjectError] when the RDF::Statement's subject is not a valid type

# File lib/rof/translators/jsonld_to_rof/statement_handler.rb, line 29
def self.call(statement, accumulator)
  new(statement, accumulator).call
  accumulator
end
new(statement, accumulator) click to toggle source

@api private

# File lib/rof/translators/jsonld_to_rof/statement_handler.rb, line 38
def self.new(statement, accumulator)
  case statement.subject
  when RDF::URI
    UriSubjectHandler.new(statement, accumulator)
  when RDF::Node
    BlankNodeHandler.new(statement, accumulator)
  else
    raise UnhandledRdfSubjectError, "Unable to determine subject handler for #{statement.inspect}"
  end
end