Class: Reliable::UUID
- Inherits:
-
Object
- Object
- Reliable::UUID
- Defined in:
- lib/reliable/uuid.rb
Instance Attribute Summary collapse
-
#random ⇒ Object
readonly
Returns the value of attribute random.
Class Method Summary collapse
Instance Method Summary collapse
- #incr ⇒ Object
-
#initialize(time, random = SecureRandom.uuid, tries = 0) {|_self| ... } ⇒ UUID
constructor
A new instance of UUID.
- #time ⇒ Object
- #to_s ⇒ Object
- #tries ⇒ Object
Constructor Details
#initialize(time, random = SecureRandom.uuid, tries = 0) {|_self| ... } ⇒ UUID
Returns a new instance of UUID.
15 16 17 18 19 20 |
# 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 |
Instance Attribute Details
#random ⇒ Object (readonly)
Returns the value of attribute random.
13 14 15 |
# File 'lib/reliable/uuid.rb', line 13 def random @random end |
Class Method Details
.parse(key) ⇒ Object
7 8 9 10 11 |
# 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 |
Instance Method Details
#incr ⇒ Object
30 31 32 |
# File 'lib/reliable/uuid.rb', line 30 def incr @tries = tries + 1 end |
#time ⇒ Object
22 23 24 |
# File 'lib/reliable/uuid.rb', line 22 def time @time.to_i end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/reliable/uuid.rb', line 34 def to_s "reliable:items:#{time}:#{random}:#{tries}" end |
#tries ⇒ Object
26 27 28 |
# File 'lib/reliable/uuid.rb', line 26 def tries @tries.to_i end |