module RDF::Util::UUID
Utilities for UUID handling.
Public Class Methods
generate(options = {})
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 [Hash{Symbol => Object}] options
any options to pass through to the underlying UUID library
@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 22 def self.generate(options = {}) begin require 'uuid' ::UUID.generate(options[:format] || :default) rescue LoadError => e begin require 'uuidtools' ::UUIDTools::UUID.random_create.hexdigest rescue LoadError => e raise LoadError.new("no such file to load -- uuid or uuidtools") end end end