Class: Captcha::Generator
- Inherits:
-
Object
- Object
- Captcha::Generator
- Defined in:
- lib/captcha/generator.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize ⇒ Generator
Returns a new instance of Generator.
3 4 5 |
# File 'lib/captcha/generator.rb', line 3 def initialize generate end |
Instance Method Details
#generate ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/captcha/generator.rb', line 7 def generate return unless Config. return if Config.last_modified && Config.last_modified > Time.now - Config.[:generate_every] path = Config.[:destination] Config.captchas.each do |captcha| FileUtils.rm_f captcha end FileUtils.mkdir_p path (1..Config.[:count]).each do |x| image = Image.new Config. path = "#{Config.[:destination]}/#{Cipher.encrypt(image.code)}.jpg" next if File.exists?(path) File.open(path, 'w') do |f| f << image.data end end GC.start end |