class DiceRoller::Dice

A class representing a single dice. Rolling this dice returns the result

Attributes

faces[RW]
value[R]

Public Class Methods

new(faces = 6) click to toggle source

create a single dice

faces: the number of sides on the dice

# File lib/dice_roller/dice.rb, line 9
def initialize(faces = 6)
  @faces = faces
  @value = nil
end

Public Instance Methods

roll() click to toggle source

roll the dice, storing and returning the resuilt

# File lib/dice_roller/dice.rb, line 15
def roll()
  @value = rand(@faces) + 1
end