Class: Chickadee::UUID

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

Constant Summary collapse

UUID_REGEX =
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/

Instance Method Summary collapse

Constructor Details

#initialize(uuid) ⇒ UUID

Returns a new instance of UUID.

Raises:

  • (ArgumentError)


5
6
7
8
# File 'lib/chickadee/vos/uuid.rb', line 5

def initialize(uuid)
  raise(ArgumentError, "invalid uuid: #{uuid}") unless uuid.is_a?(String) && uuid.match(UUID_REGEX)
  @uuid = uuid
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/chickadee/vos/uuid.rb', line 14

def ==(other)
  self.class == other.class && self.hash == other.hash
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/chickadee/vos/uuid.rb', line 18

def eql?(other)
  self == other
end

#hashObject



22
23
24
# File 'lib/chickadee/vos/uuid.rb', line 22

def hash
  @uuid.hash
end

#to_sObject



10
11
12
# File 'lib/chickadee/vos/uuid.rb', line 10

def to_s
  @uuid
end