Class: IdGenerator::Generators::TimestampedRandom
- Inherits:
-
Object
- Object
- IdGenerator::Generators::TimestampedRandom
- Defined in:
- lib/id_generator/generators/timestamped_random.rb
Constant Summary collapse
- COUNTER_PART_SIZE =
8- CONTEXT_PART_SIZE =
2- RANDOM_PART_BYTES =
11- COUNTER_START =
Time.new(2000).to_i
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(config) ⇒ TimestampedRandom
constructor
A new instance of TimestampedRandom.
Constructor Details
#initialize(config) ⇒ TimestampedRandom
Returns a new instance of TimestampedRandom.
14 15 16 |
# File 'lib/id_generator/generators/timestamped_random.rb', line 14 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/id_generator/generators/timestamped_random.rb', line 12 def config @config end |
Instance Method Details
#generate ⇒ Object
18 19 20 |
# File 'lib/id_generator/generators/timestamped_random.rb', line 18 def generate "#{time}-#{context_id}-#{random_number}" end |