Class: Kamcaptcha::Generator::WordGenerator
- Inherits:
-
Object
- Object
- Kamcaptcha::Generator::WordGenerator
- Defined in:
- lib/kamcaptcha/generator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
-
#initialize(length) ⇒ WordGenerator
constructor
A new instance of WordGenerator.
Constructor Details
#initialize(length) ⇒ WordGenerator
Returns a new instance of WordGenerator.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kamcaptcha/generator.rb', line 13 def initialize(length) if length.to_s =~ /^(\d+)$/ @min = @max = $1.to_i elsif length =~ /^(\d+)-(\d+)$/ @min = [$1.to_i, $2.to_i].min @max = [$1.to_i, $2.to_i].max else raise ArgumentError.new("Invalid word length specified: #{length}") end end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
11 12 13 |
# File 'lib/kamcaptcha/generator.rb', line 11 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
11 12 13 |
# File 'lib/kamcaptcha/generator.rb', line 11 def min @min end |