Class: Wee::IdGenerator::Sequential
- Inherits:
-
Wee::IdGenerator
- Object
- Wee::IdGenerator
- Wee::IdGenerator::Sequential
- Defined in:
- lib/wee/id_generator.rb
Overview
Sequential id generator.
Returned ids are guaranteed to be unique, but they are easily guessable.
Instance Method Summary collapse
-
#initialize(initial_value = 0) ⇒ Sequential
constructor
A new instance of Sequential.
- #next ⇒ Object
Constructor Details
#initialize(initial_value = 0) ⇒ Sequential
Returns a new instance of Sequential.
18 19 20 |
# File 'lib/wee/id_generator.rb', line 18 def initialize(initial_value=0) @value = initial_value - 1 end |
Instance Method Details
#next ⇒ Object
22 23 24 |
# File 'lib/wee/id_generator.rb', line 22 def next (@value += 1).to_s(36) end |