Class: JSON::LD::BlankNodeMapper

Inherits:
Hash
  • Object
show all
Defined in:
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

Instance Method Details

#get_name(old = "") ⇒ String

Get a new mapped name for old

Parameters:

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

    ("")

Returns:

  • (String)

256
257
258
# File 'lib/json/ld/utils.rb', line 256

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:

  • (String)

246
247
248
249
# File 'lib/json/ld/utils.rb', line 246

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