class RolledDice
This class represents the result of a roll, for people that need to work wit dice details.
@author Cédric ZUGER
Attributes
result[R]
rolls[R]
Public Class Methods
new(rolls)
click to toggle source
Create a RolledDice
object
@param rolls [Array] an array of integer containing the dice rolls.
# File lib/rolled_dice.rb, line 11 def initialize(rolls) @rolls = rolls @result = rolls.reduce(:+) end
Public Instance Methods
==(rolled_dice)
click to toggle source
Compare two rolls
@param rolled_dice [RolledDice] the other RolledDice
to compare
@return [Boolean] the result of the comparison
# File lib/rolled_dice.rb, line 21 def ==(rolled_dice) @rolls == rolled_dice.rolls && @result == rolled_dice.result end