Class: HumanizedId::RandGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/humanized_id/rand_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix: '', length:) ⇒ RandGenerator

Returns a new instance of RandGenerator.



4
5
6
7
8
# File 'lib/humanized_id/rand_generator.rb', line 4

def initialize(prefix: '', length:)
  @prefix = prefix.nil? ? '' : prefix
  @length = length
  @target_charset = CHARSET
end

Instance Method Details

#generate_random_humanized_idObject



10
11
12
# File 'lib/humanized_id/rand_generator.rb', line 10

def generate_random_humanized_id
  "#{@prefix}#{generate_random}"
end