class Rubeyond::UUID

The UUID class handles representing a universally unique identifier.

Examples

# Create a new unique UUID.
@uuid = Rubeyond::UUID.create

# Create an instance of UUID from a uuid value.
@uuid = Rubeyond::UUID.create :uuid => "fd0289a5-8eec-4a08-9283-81d02c9d2fff"

# Create an instance of UUID from an encoded value.
@uuid = Rubeyond::UUID.create :encoded => 336307859334295828133695192821923655679

Attributes

encoded[R]

The encoded value of the UUID.

uuid[R]

A string representation of the UUID.

Public Class Methods

create(options = {}) click to toggle source

Creates a new UUID instance.

If provided, it will create a new instances with the given uuid value.

Attributes

  • options - creation options

Options

  • +:uuid: - the UUID value to use

  • +:encoded: - an encoded UUID

# File lib/rubeyond/uuid.rb, line 55
def self.create(options = {})
  # if we have a uuid then create from that
  if options[:uuid]
    Rubeyond::UUID.new(options[:uuid])
  elsif options[:encoded]
    uuid = decode(options[:encoded])
    Rubeyond::UUID.new(uuid)
  else
    Rubeyond::UUID.new
  end
end

Public Instance Methods

to_s() click to toggle source

Returns a string representation of the UUID.

# File lib/rubeyond/uuid.rb, line 84
def to_s
  @uuid
end