Class: DsaCodebreakerGame::Code

Inherits:
Array
  • Object
show all
Defined in:
lib/dsa_codebreaker_game/code.rb

Constant Summary collapse

COLORS =

Available colours red®, orange (O), yellow (Y), green (G), blue (B), Indigo (I), and violet (V).

['R', 'O', 'Y', 'G', 'B', 'I', 'V']

Instance Method Summary collapse

Constructor Details

#initializeCode

Returns a new instance of Code.



8
9
10
11
12
# File 'lib/dsa_codebreaker_game/code.rb', line 8

def initialize
  4.times do
    self << randomizer
  end
end

Instance Method Details

#randomizerObject



14
15
16
# File 'lib/dsa_codebreaker_game/code.rb', line 14

def randomizer
  COLORS[rand(0..6)]
end