Class: JSON::LD::BlankNodeMapper

Inherits:
Hash show all
Defined in:
vendor/bundler/ruby/3.2.0/bundler/gems/json-ld-cb5ef847d963/lib/json/ld/utils.rb

Overview

Utility class for mapping old blank node identifiers, or unnamed blank nodes to new identifiers

Direct Known Subclasses

BlankNodeNamer, BlankNodeUniqer

Instance Method Summary collapse

Methods inherited from Hash

#deep_dup, #optimize, #to_sxp

Instance Method Details

#get_name(old = "") ⇒ String

Get a new mapped name for old

Parameters:

  • old (String) (defaults to: "")

    ("")

Returns:



261
262
263
# File 'vendor/bundler/ruby/3.2.0/bundler/gems/json-ld-cb5ef847d963/lib/json/ld/utils.rb', line 261

def get_name(old = "")
  "_:" + get_sym(old)
end

#get_sym(old = "") ⇒ String

Just return a Blank Node based on old. Manufactures a node if old is nil or empty

Parameters:

  • old (String) (defaults to: "")

    ("")

Returns:



251
252
253
254
# File 'vendor/bundler/ruby/3.2.0/bundler/gems/json-ld-cb5ef847d963/lib/json/ld/utils.rb', line 251

def get_sym(old = "")
  old = RDF::Node.new.to_s if old.to_s.empty?
  old.to_s.sub(/_:/, '')
end