Class: Roll
- Inherits:
-
Array
- Object
- Array
- Roll
- Defined in:
- lib/craps_dice.rb
Instance Method Summary collapse
- #dup ⇒ Object
-
#initialize ⇒ Roll
constructor
A new instance of Roll.
- #is_hard? ⇒ Boolean
- #is_seven? ⇒ Boolean
- #name ⇒ Object
- #reroll ⇒ Object
Constructor Details
#initialize ⇒ Roll
Returns a new instance of Roll.
7 8 9 |
# File 'lib/craps_dice.rb', line 7 def initialize 2.times { push(rand(1..6)) } end |
Instance Method Details
#dup ⇒ Object
31 32 33 |
# File 'lib/craps_dice.rb', line 31 def dup Marshal.load(Marshal.dump(self)) end |
#is_hard? ⇒ Boolean
17 18 19 |
# File 'lib/craps_dice.rb', line 17 def is_hard? uniq.length == 1 end |
#is_seven? ⇒ Boolean
21 22 23 |
# File 'lib/craps_dice.rb', line 21 def is_seven? sum == 7 end |
#name ⇒ Object
25 26 27 28 29 |
# File 'lib/craps_dice.rb', line 25 def name ROLL_NAMES.find { |key, values| values.include?(self.sort) }.first end |
#reroll ⇒ Object
11 12 13 14 15 |
# File 'lib/craps_dice.rb', line 11 def reroll clear 2.times { push(rand(1..6)) } self end |