Class: SuperRandom::Dice
- Inherits:
-
Object
- Object
- SuperRandom::Dice
- Defined in:
- lib/super_random.rb
Instance Method Summary collapse
-
#initialize(sides, minimum: 1, rng: SuperRandom.new) ⇒ Dice
constructor
A new instance of Dice.
- #roll ⇒ Object
Constructor Details
#initialize(sides, minimum: 1, rng: SuperRandom.new) ⇒ Dice
Returns a new instance of Dice.
81 82 83 84 |
# File 'lib/super_random.rb', line 81 def initialize(sides, minimum:1, rng:SuperRandom.new) @sides,@minimum,@rng = sides,minimum,rng set_big end |
Instance Method Details
#roll ⇒ Object
85 86 87 88 89 90 |
# File 'lib/super_random.rb', line 85 def roll @big,roll = @big.divmod(@sides) return roll+@minimum ensure set_big unless @big>0 end |