Class: EventStoreClient::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/event_store_client/utils.rb

Class Method Summary collapse

Class Method Details

.uuid_to_str(uuid) ⇒ String

Parameters:

Returns:

  • (String)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/event_store_client/utils.rb', line 10

def uuid_to_str(uuid)
  return uuid.string unless uuid.string.empty?

  msb =
    if uuid.structured.most_significant_bits.negative?
      (2**64) + uuid.structured.most_significant_bits
    else
      uuid.structured.most_significant_bits
    end
  lsb =
    if uuid.structured.least_significant_bits.negative?
      (2**64) + uuid.structured.least_significant_bits
    else
      uuid.structured.least_significant_bits
    end
  (msb.to_s(16) + lsb.to_s(16)).unpack('A8A4A4A4A12').join('-')
end