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.
84 85 86 87 |
# File 'lib/super_random.rb', line 84 def initialize(sides, minimum:1, rng:SuperRandom.new) @sides,@minimum,@rng = sides,minimum,rng set_big end |
Instance Method Details
#roll ⇒ Object
88 89 90 91 92 93 |
# File 'lib/super_random.rb', line 88 def roll @big,roll = @big.divmod(@sides) roll+@minimum ensure set_big unless @big.positive? end |