Class: UUIDGen::UUID

Inherits:
Object
  • Object
show all
Defined in:
lib/uuidgen/uuid.rb

Direct Known Subclasses

NameBasedUUID, NameSpace

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#decimalObject (readonly)

Returns the value of attribute decimal.



3
4
5
# File 'lib/uuidgen/uuid.rb', line 3

def decimal
  @decimal
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/uuidgen/uuid.rb', line 20

def eql?(other)
  @decimal == other.decimal
end

#hashObject



24
25
26
# File 'lib/uuidgen/uuid.rb', line 24

def hash
  @decimal.hash
end

#to_hexObject



5
6
7
# File 'lib/uuidgen/uuid.rb', line 5

def to_hex
  @decimal.to_s(16).rjust(32, '0')
end

#to_sObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/uuidgen/uuid.rb', line 9

def to_s
  hex_string = to_hex
  '%s-%s-%s-%s-%s' % [
    hex_string[0, 8],
    hex_string[8, 4],
    hex_string[12, 4],
    hex_string[16, 4],
    hex_string[20, 12]
  ]
end