Class: StudioGame::Die
- Inherits:
-
Object
- Object
- StudioGame::Die
- Includes:
- Auditable
- Defined in:
- lib/studio_game/die.rb
Constant Summary collapse
- @@roll_counts =
[0, 0, 0, 0, 0, 0, 0]
Instance Attribute Summary collapse
-
#last_roll ⇒ Object
readonly
Returns the value of attribute last_roll.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Die
constructor
A new instance of Die.
- #roll ⇒ Object
Methods included from Auditable
Constructor Details
#initialize ⇒ Die
Returns a new instance of Die.
11 12 13 |
# File 'lib/studio_game/die.rb', line 11 def initialize # @last_roll = roll end |
Instance Attribute Details
#last_roll ⇒ Object (readonly)
Returns the value of attribute last_roll.
7 8 9 |
# File 'lib/studio_game/die.rb', line 7 def last_roll @last_roll end |
Class Method Details
.report_rolls ⇒ Object
23 24 25 |
# File 'lib/studio_game/die.rb', line 23 def self.report_rolls puts "\nDie Counts: #{@@roll_counts.join(", ")}" end |
Instance Method Details
#roll ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/studio_game/die.rb', line 15 def roll @last_roll = rand(1..6) @number = @last_roll audit @@roll_counts[@last_roll] += 1 return @last_roll end |