Class: EllipticCurve::Utils::RandomInteger

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

Class Method Summary collapse

Class Method Details

.between(min, max) ⇒ Object

Parameters (required): :param min: minimum value of the integer :param max: maximum value of the integer :return: A random number between min and max



12
13
14
15
16
17
18
19
20
# File 'lib/utils/integer.rb', line 12

def self.between(min, max)
    if (max - min) < 0 then
        raise Exception.new("max must be greater than min")
    end
    if (max - min) > 0 then
        return SecureRandom.random_number((max + 1) - min) + min
    end
    return min
end