Class: CodeGenerator
- Inherits:
-
Object
- Object
- CodeGenerator
- Defined in:
- lib/code_generator.rb
Overview
generates a random code of 4 characters
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
-
#new_code ⇒ Object
readonly
Returns the value of attribute new_code.
Instance Method Summary collapse
-
#initialize ⇒ CodeGenerator
constructor
A new instance of CodeGenerator.
- #secret_code ⇒ Object
Constructor Details
#initialize ⇒ CodeGenerator
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
#array ⇒ Object (readonly)
Returns the value of attribute array.
4 5 6 |
# File 'lib/code_generator.rb', line 4 def array @array end |
#new_code ⇒ Object (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_code ⇒ Object
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 |