Class: Captcha_img

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCaptcha_img

Returns a new instance of Captcha_img.



2
3
# File 'lib/captcha_img.rb', line 2

def initialize
end

Class Method Details

.arrayObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/captcha_img.rb', line 5

def self.array
action= [ "+" , "-" , "*" ]

    r = Random.new
    @no1=r.rand(1..9)
    a = @no1
    @no2=r.rand(1..9)
    b = @no2
   # no2=@no[r.rand(9)]
    ac= action[rand(3)]
   
    if ac=='-'
     if a<b
         temp = a
         a = b
         b = temp
     end
    end
    
    ans = eval "#{a}#{ac}#{b}"
    cap_view = "#{a} #{ac} #{b} = "
   
    result = "#{ans}~ #{cap_view}"
#    @source = ans + "~" + cap_view
 #   puts result
#        cap_view = "#{@no_letter[no1]} #{@action[ac]} #{@no_letter[no2]}"
 #   puts ans
  #  puts cap_view
    return result

end