class Reliable::UUID

Attributes

random[R]

Public Class Methods

new(time, random = SecureRandom.uuid, tries = 0) { |self| ... } click to toggle source
# File lib/reliable/uuid.rb, line 15
def initialize(time, random = SecureRandom.uuid, tries = 0)
  @time = time
  @random = random
  @tries = tries || 0
  yield(self) if block_given?
end
parse(key) click to toggle source
# File lib/reliable/uuid.rb, line 7
def self.parse(key)
  _, _, time, random, tries = key.split(":")
  raise MalformedUUID unless time && random && tries
  new(time, random, tries)
end

Public Instance Methods

incr() click to toggle source
# File lib/reliable/uuid.rb, line 30
def incr
  @tries = tries + 1
end
time() click to toggle source
# File lib/reliable/uuid.rb, line 22
def time
  @time.to_i
end
to_s() click to toggle source
# File lib/reliable/uuid.rb, line 34
def to_s
  "reliable:items:#{time}:#{random}:#{tries}"
end
tries() click to toggle source
# File lib/reliable/uuid.rb, line 26
def tries
  @tries.to_i
end