Class: Codebreaker::Guess
Constant Summary collapse
- VALID_GUESS_LENGTH =
4
- VALID_GUESS_RANGE =
('0'..'6').freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#number ⇒ Object
Returns the value of attribute number.
Instance Method Summary collapse
-
#initialize(guess) ⇒ Guess
constructor
A new instance of Guess.
- #validate ⇒ Object
Methods inherited from BaseClass
Methods included from Validator
#check_length?, #check_length_in_range?, #check_number_in_range?, #check_symbols_in_range?
Constructor Details
#initialize(guess) ⇒ Guess
Returns a new instance of Guess.
11 12 13 14 |
# File 'lib/entities/guess.rb', line 11 def initialize(guess) @number = guess @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/entities/guess.rb', line 9 def errors @errors end |
#number ⇒ Object
Returns the value of attribute number.
8 9 10 |
# File 'lib/entities/guess.rb', line 8 def number @number end |
Instance Method Details
#validate ⇒ Object
16 17 18 19 |
# File 'lib/entities/guess.rb', line 16 def validate @errors << 'error_number_length' unless check_length?(@number, VALID_GUESS_LENGTH) @errors << 'error_number_digit' unless check_number_in_range?(@number, VALID_GUESS_RANGE) end |