Class: Die
- Inherits:
-
Object
- Object
- Die
- Defined in:
- lib/dice.rb
Overview
Super-simple dice roller. Get your nerd on.
Defined Under Namespace
Modules: Roller
Instance Method Summary collapse
-
#initialize(sides = 20) ⇒ Die
constructor
set up a die.
-
#roll(number = 1) ⇒ Object
roll a given number of these dice.
Constructor Details
#initialize(sides = 20) ⇒ Die
set up a die
5 6 7 |
# File 'lib/dice.rb', line 5 def initialize sides=20 @sides = sides.to_i end |
Instance Method Details
#roll(number = 1) ⇒ Object
roll a given number of these dice
10 11 12 13 14 |
# File 'lib/dice.rb', line 10 def roll number = 1 rolls = [] number.to_i.times { rolls << (rand(@sides) + 1).to_i } rolls end |