Module: ULID
- Includes:
- Constants
- Defined in:
- lib/ulid.rb,
lib/ulid/parse.rb,
lib/ulid/compare.rb,
lib/ulid/version.rb,
lib/ulid/generate.rb,
lib/ulid/constants.rb,
lib/ulid/identifier.rb
Defined Under Namespace
Modules: Compare, Constants, Generate, Parse Classes: Identifier
Constant Summary collapse
- VERSION =
"1.0.2"
Constants included from Constants
Constants::B32REF, Constants::ENCODING, Constants::MAX_ENTROPY, Constants::MAX_TIME, Constants::MIN_ENTROPY, Constants::MIN_TIME
Class Method Summary collapse
-
.at(at_time) ⇒ String
Get a string ULID encoding the given time.
-
.generate ⇒ String
Get a new, randomized ULID string at the current time.
-
.max_ulid_at(at_time) ⇒ String
Get the first possible ULID string for the given time in sort order descending.
-
.min_ulid_at(at_time) ⇒ String
Get the first possible ULID string for the given time in sort order ascending.
-
.new(*args) ⇒ ULID::Identifier
Get a new, randomized ULID::Identifier instance at the current time.
-
.time(ulid) ⇒ Time
Get the Time value encoded by the given ULID string.
Class Method Details
.at(at_time) ⇒ String
Get a string ULID encoding the given time.
45 46 47 |
# File 'lib/ulid.rb', line 45 def self.at(at_time) Identifier.new(at_time).ulid end |
.generate ⇒ String
Get a new, randomized ULID string at the current time.
33 34 35 |
# File 'lib/ulid.rb', line 33 def self.generate Identifier.new.ulid end |
.max_ulid_at(at_time) ⇒ String
Get the first possible ULID string for the given time in sort order descending.
81 82 83 |
# File 'lib/ulid.rb', line 81 def self.max_ulid_at(at_time) Identifier.new(at_time, MAX_ENTROPY).ulid end |
.min_ulid_at(at_time) ⇒ String
Get the first possible ULID string for the given time in sort order ascending.
69 70 71 |
# File 'lib/ulid.rb', line 69 def self.min_ulid_at(at_time) Identifier.new(at_time, MIN_ENTROPY).ulid end |
.new(*args) ⇒ ULID::Identifier
Get a new, randomized ULID::Identifier instance at the current time.
22 23 24 |
# File 'lib/ulid.rb', line 22 def self.new(*args) Identifier.new(*args) end |
.time(ulid) ⇒ Time
Get the Time value encoded by the given ULID string.
57 58 59 |
# File 'lib/ulid.rb', line 57 def self.time(ulid) Identifier.new(ulid).time.utc end |