Module: ROF::Translators::JsonldToRof::PredicateHandler

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

Overview

Responsible for dealing with registered predicates and how those are handled.

API:

  • public

Defined Under Namespace

Classes: UnhandledPredicateError

Class Method Summary collapse

Class Method Details

.call(predicate, object, accumulator, blank_node = false) ⇒ 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 predicate and RDF object 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//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

Raises:

  • when we are unable to handle the given predicate

Parameters:

    • the RDF predicate that we will parse and add to the appropriate spot in the accumulator

    • the RDF object that we will parse and add to the appropriate spot in the accumulator

    • a data accumulator that will be changed in place

Returns:

  • the given accumulator

API:

  • public



34
35
36
37
38
# File 'lib/rof/translators/jsonld_to_rof/predicate_handler.rb', line 34

def self.call(predicate, object, accumulator, blank_node = false)
  handler = registry.handler_for(predicate)
  handler.handle(object, accumulator, blank_node)
  accumulator
end

.register(url) {|| ... } ⇒ Object

Yields:

  • The block to configure how we handle RDF Predicates that match the gvien URL

Yield Parameters:

  • (ROF::JsonldToRof::PredicateHandler::UrlHandler)

See Also:

  • for details and usage usage

Parameters:

    • The URL that we want to match against

API:

  • public



45
46
47
# File 'lib/rof/translators/jsonld_to_rof/predicate_handler.rb', line 45

def self.register(url, &block)
  registry << UrlHandler.new(url, &block)
end