Module: ULID::Generator
- Included in:
- ULID
- Defined in:
- lib/ulid/generator.rb
Constant Summary collapse
- ENCODING =
Crockford’s Base32
'0123456789ABCDEFGHJKMNPQRSTVWXYZ'.bytes.freeze
- RANDOM_BYTES =
10
- ENCODED_LENGTH =
26
- BIT_LENGTH =
128
- BITS_PER_B32_CHAR =
5
- ZERO =
'0'.ord
- MASK =
0x1f
Instance Method Summary collapse
Instance Method Details
#generate(time = Time.now) ⇒ Object
20 21 22 23 24 |
# File 'lib/ulid/generator.rb', line 20 def generate(time = Time.now) input = octo_word(time) encode(input, ENCODED_LENGTH) end |
#generate_bytes(time = Time.now) ⇒ Object
26 27 28 |
# File 'lib/ulid/generator.rb', line 26 def generate_bytes(time = Time.now) time_48bit(time) + random_bytes end |