Class: Kamcaptcha::Generator::RandomWordGenerator

Inherits:
WordGenerator
  • Object
show all
Defined in:
lib/kamcaptcha/generator.rb

Constant Summary collapse

CHARS =
"23456789ABCDEFGHJKLMNPQRSTUVXYZ".split("")

Instance Attribute Summary

Attributes inherited from WordGenerator

#max, #min

Instance Method Summary collapse

Methods inherited from WordGenerator

#initialize

Constructor Details

This class inherits a constructor from Kamcaptcha::Generator::WordGenerator

Instance Method Details

#generateObject



28
29
30
31
32
33
# File 'lib/kamcaptcha/generator.rb', line 28

def generate
  length  = min
  length += Kernel.rand(max - min) unless max == min

  (1..length).map { CHARS[rand(CHARS.size)] }.join(" ")
end