module ROF::Translators::JsonldToRof::PredicateObjectHandler
We need to handle the Predicate / Object
pair as one (thank you RDF blank nodes for this nuance)
@see ROF::Translators::JsonldToRof::PredicateObjectHandler.call
Public Class Methods
@api public
Parse the RDF::Predicate, RDF::Object and the relevant data to the contents to the accumulator
@example
Given the following 4 RDF N-Triples (subject, predicate, object). The first and second RDF objects are RDF::Literal. The 3rd triple's object is and RDF::Node. And the last is an RDF::URI. Each require different handlers as they have nuanced differences. _: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> .
@note It is assumed that all blank nodes (e.g. RDF::Node) will be processed before you process any RDF::URI nodes.
@param [RDF::Predicate] predicate - the RDF predicate that we will parse and add to the appropriate spot in the accumulator @param [RDF::Object] object - the RDF object 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::UnknownRdfObjectTypeError] when the RDF::Object's subject is not a valid type
# File lib/rof/translators/jsonld_to_rof/predicate_object_handler.rb, line 30 def self.call(predicate, object, accumulator, options = {}) new(predicate, object, accumulator, options).call accumulator end
Private Class Methods
@api private
# File lib/rof/translators/jsonld_to_rof/predicate_object_handler.rb, line 50 def self.klass_for(object) case object when RDF::URI UriPredicateObjectHandler when RDF::Node NodePredicateObjectHandler when RDF::Literal LiteralPredicateObjectHandler else raise UnknownRdfObjectTypeError, "Unable to determine object handler for #{object.inspect}" end end
@api private
@param [RDF::Predicate] predicate - the RDF predicate that we will parse and add to the appropriate spot in the accumulator @param [RDF::Object] object - the RDF object 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 [#call]
# File lib/rof/translators/jsonld_to_rof/predicate_object_handler.rb, line 41 def self.new(predicate, object, accumulator, options) klass_for(object).new(predicate, object, accumulator, options) end