Module: ROF::Translators::JsonldToRof::StatementHandler

Defined in:
lib/rof/translators/jsonld_to_rof/statement_handler.rb

Overview

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

Defined Under Namespace

Classes: UnhandledRdfSubjectError

Class Method Summary collapse

Class Method Details

.call(statement, accumulator) ⇒ ROF::Translators::JsonldToRof::Accumulator

Note:

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

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

Examples:

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

Parameters:

  • statement (RDF::Statement)
    • the RDF statement that we will parse and add to the appropriate spot in the accumulator

  • accumulator (ROF::Translators::JsonldToRof::Accumulator)
    • a data accumulator that will be changed in place

Returns:

Raises:

  • (ROF::Translators::JsonldToRof::UnhandledRdfSubjectError)

    when the RDF::Statement’s subject is not a valid type



29
30
31
32
# 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) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
42
43
44
45
46
47
# 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