Class: Rassphrase::Dice

Inherits:
Object
  • Object
show all
Defined in:
lib/rassphrase/dice.rb

Overview

Simulates a dice

Instance Method Summary collapse

Constructor Details

#initializeDice

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

#rollObject

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_countObject

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