module RDF::Util::UUID
Utilities for UUID
handling.
Public Class Methods
generate(format: :default)
click to toggle source
Generates a UUID
string.
This will make use of either the [UUID][] gem or the [UUIDTools][] gem, whichever of the two happens to be available.
[UUID]: rubygems.org/gems/uuid [UUIDTools]: rubygems.org/gems/uuidtools
@param [:default, :compact, :urn] format (:default) @return [String] a UUID
string @raise [LoadError] if no UUID
library is available @see rubygems.org/gems/uuid @see rubygems.org/gems/uuidtools
# File lib/rdf/util/uuid.rb, line 21 def self.generate(format: :default) begin require 'uuid' ::UUID.generate(format) rescue LoadError begin require 'uuidtools' ::UUIDTools::UUID.random_create.hexdigest rescue LoadError raise LoadError.new("no such file to load -- uuid or uuidtools") end end end