Class: Rassphrase::Dice
- Inherits:
-
Object
- Object
- Rassphrase::Dice
- Defined in:
- lib/rassphrase/dice.rb
Overview
Simulates a dice
Instance Method Summary collapse
-
#initialize ⇒ Dice
constructor
Creates a new instance of a dice.
-
#roll ⇒ Object
Returns a random number between 1 and the number of sides in the dice.
-
#roll_count ⇒ Object
Indicates the number of times the dice has been rolled.
Constructor Details
#initialize ⇒ Dice
Creates a new instance of a dice
5 6 7 8 |
# File 'lib/rassphrase/dice.rb', line 5 def initialize @random = Random.new @roll_count = 0 end |
Instance Method Details
#roll ⇒ Object
Returns a random number between 1 and the number of sides in the dice.
12 13 14 15 |
# File 'lib/rassphrase/dice.rb', line 12 def roll @roll_count += 1 @random.rand(1..6) end |
#roll_count ⇒ Object
Indicates the number of times the dice has been rolled.
19 20 21 |
# File 'lib/rassphrase/dice.rb', line 19 def roll_count @roll_count end |