Class: 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.
10 11 12 13 |
# File 'lib/entities/guess.rb', line 10 def initialize(guess) @number = guess @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/entities/guess.rb', line 8 def errors @errors end |
#number ⇒ Object
Returns the value of attribute number.
7 8 9 |
# File 'lib/entities/guess.rb', line 7 def number @number end |
Instance Method Details
#validate ⇒ Object
15 16 17 18 |
# File 'lib/entities/guess.rb', line 15 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 |