Class: StudioGame::Die

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Auditable

#audit

Constructor Details

#initializeDie

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_rollObject (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_rollsObject



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

#rollObject



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