Class: JSON::LD::BlankNodeMapper

Inherits:
Hash show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/json-ld-10f0d539c024/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

#to_sxp, #to_sxp_bin

Instance Method Details

#get_name(old = "") ⇒ String

Get a new mapped name for old

Parameters:

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

    ("")

Returns:



242
243
244
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/json-ld-10f0d539c024/lib/json/ld/utils.rb', line 242

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:



232
233
234
235
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/json-ld-10f0d539c024/lib/json/ld/utils.rb', line 232

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