Class: Budik::Rng
- Inherits:
-
Object
- Object
- Budik::Rng
- Defined in:
- lib/budik/rng.rb
Overview
‘Rng’ class provides various methods for random number generation.
Instance Attribute Summary collapse
-
#method ⇒ Object
Gets RNG options and method.
-
#options ⇒ Object
Gets RNG options and method.
Instance Method Summary collapse
-
#generate(items) ⇒ Object
Generates random number.
-
#initialize ⇒ Rng
constructor
Loads RNG options including method.
Constructor Details
Instance Attribute Details
#method ⇒ Object
Gets RNG options and method.
20 21 22 |
# File 'lib/budik/rng.rb', line 20 def method @method end |
#options ⇒ Object
Gets RNG options and method.
20 21 22 |
# File 'lib/budik/rng.rb', line 20 def @options end |
Instance Method Details
#generate(items) ⇒ Object
Generates random number.
-
Args:
-
items
-> Total number of items (Fixnum).
-
-
Returns:
-
Fixnum (0…items)
-
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/budik/rng.rb', line 29 def generate(items) case @method when 'hwrng' hwrng(@options['hwrng'], items) when 'random.org' random_org(@options['random.org'], items) when 'rand-hwrng-seed' swrng(items, hwrng(@options['hwrng'], 2**64)) else swrng(items) end end |