Sha256: db18b71560059615297bd8928ce2aa8da880cb2b64fe8aedaa02153f9ea2a4f2
Contents?: true
Size: 602 Bytes
Versions: 5
Compression:
Stored size: 602 Bytes
Contents
# This class represents the result of a roll, for people that need to work wit dice details. # # @author Cédric ZUGER class RolledDice attr_reader :result, :rolls # Create a RolledDice object # # @param rolls [Array] an array of integer containing the dice rolls. def initialize(rolls) @rolls = rolls @result = rolls.reduce(:+) end # Compare two rolls # # @param rolled_dice [RolledDice] the other RolledDice to compare # # @return [Boolean] the result of the comparison def ==(rolled_dice) @rolls == rolled_dice.rolls && @result == rolled_dice.result end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
hazard-1.3.4 | lib/rolled_dice.rb |
hazard-1.3.3 | lib/rolled_dice.rb |
hazard-1.3.2 | lib/rolled_dice.rb |
hazard-1.3.1 | lib/rolled_dice.rb |
hazard-1.3.0 | lib/rolled_dice.rb |