Class: Andromeda::Id

Inherits:
Andromeda::Impl::XorId show all
Defined in:
lib/andromeda/id.rb

Constant Summary collapse

DEFAULT_NUM_BYTES =

Default length of generated ids

8

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Andromeda::Impl::XorId

#==, #[], #clone_to_copy?, #each, #each_with_index, #hash, #identical_copy, #inspect, #length, #same_length?, #to_short_s, #xor, #zero?

Methods included from Andromeda::Impl::To_S

short_s, #to_s, #to_short_s

Constructor Details

#initialize(random = true) ⇒ Id

Returns a new instance of Id.

Parameters:

  • random (Bool) (defaults to: true)


8
9
10
# File 'lib/andromeda/id.rb', line 8

def initialize(random = true)
  super DEFAULT_NUM_BYTES, random
end

Class Method Details

.zeroId

Returns empty (zero) id.

Returns:

  • (Id)

    empty (zero) id



13
14
15
16
# File 'lib/andromeda/id.rb', line 13

def self.zero
  @id = self.new false unless defined? @id
  @id
end