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)


261
262
263
# File '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:

  • (String)


251
252
253
254
# File '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