Class: Captchah::Generators::Truth
- Inherits:
-
Object
- Object
- Captchah::Generators::Truth
- Defined in:
- lib/captchah/generators/truth.rb
Class Method Summary collapse
Class Method Details
.call(difficulty) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/captchah/generators/truth.rb', line 6 def self.call(difficulty) chrs = [] (rand(0..1).positive? ? 4 : 5).times do up_or_down = rand(0..1).positive? && difficulty > 1 && difficulty != 3 chr = (up_or_down ? rand(97..122) : rand(65..90)).chr chrs << (%w[i j l r].any? { |c| c == chr } ? chr.upcase : chr) end chrs.join end |