class JSON::LD::BlankNodeNamer
Public Class Methods
new(prefix)
click to toggle source
@param [String] prefix
Calls superclass method
# File lib/json/ld/utils.rb, line 279 def initialize(prefix) @prefix = prefix.to_s @num = 0 super end
Public Instance Methods
get_sym(old = "")
click to toggle source
Get a new symbol mapped from `old` @param [String] old (“”) @return [String]
# File lib/json/ld/utils.rb, line 289 def get_sym(old = "") old = old.to_s.sub(/_:/, '') if !old.empty? && self.key?(old) self[old] elsif !old.empty? @num += 1 #puts "allocate #{@prefix + (@num - 1).to_s} to #{old.inspect}" self[old] = @prefix + (@num - 1).to_s else # Not referenced, just return a new unique value @num += 1 #puts "allocate #{@prefix + (@num - 1).to_s} to #{old.inspect}" @prefix + (@num - 1).to_s end end