Class: Kodo::Algorithms::Random

Inherits:
Base
  • Object
show all
Defined in:
lib/kodo/algorithms/random.rb

Constant Summary collapse

DEFAULT_LENGTH =
16

Constants inherited from Base

Base::DEFAULT_SEED_LIBRARY

Instance Attribute Summary

Attributes inherited from Base

#count, #max_length, #name, #seed

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Kodo::Algorithms::Base

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kodo/algorithms/random.rb', line 6

def create
  if @max_length.nil?
    @max_length = DEFAULT_LENGTH
  end

  for i in 1..@count do
    rnd_array = []

    for l in 1..@max_length do
      rnd_array << ('0'..'z').to_a.shuffle.first(1).join
    end

    puts rnd_array.join
  end
end