Class: CodeGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/code_generator.rb

Overview

generates a random code of 4 characters

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCodeGenerator

Returns a new instance of CodeGenerator.



7
8
9
10
# File 'lib/code_generator.rb', line 7

def initialize
  @array = ['r','r','r','r','g','g','g','g','b','b','b','b','y','y','y','y']
  @new_code = []
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



4
5
6
# File 'lib/code_generator.rb', line 4

def array
  @array
end

#new_codeObject (readonly)

Returns the value of attribute new_code.



4
5
6
# File 'lib/code_generator.rb', line 4

def new_code
  @new_code
end

Instance Method Details

#secret_codeObject



12
13
14
# File 'lib/code_generator.rb', line 12

def secret_code
  @new_code = @array.shuffle!.pop(4) #could use shift instead of pop?
end