Class: CodebreakerGem::Guess
- Inherits:
-
ValidatedEntity
- Object
- ValidatedEntity
- CodebreakerGem::Guess
- Defined in:
- lib/app/entities/guess.rb
Constant Summary collapse
- ELEMENT_VALUE_RANGE =
(1..6).freeze
- HINT =
'hint'
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#guess_code ⇒ Object
readonly
Returns the value of attribute guess_code.
Instance Method Summary collapse
- #hint? ⇒ Boolean
-
#initialize(guess_code) ⇒ Guess
constructor
A new instance of Guess.
- #validate ⇒ Object
Methods inherited from ValidatedEntity
Constructor Details
#initialize(guess_code) ⇒ Guess
Returns a new instance of Guess.
11 12 13 14 |
# File 'lib/app/entities/guess.rb', line 11 def initialize(guess_code) super() @guess_code = guess_code end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/app/entities/guess.rb', line 5 def errors @errors end |
#guess_code ⇒ Object (readonly)
Returns the value of attribute guess_code.
5 6 7 |
# File 'lib/app/entities/guess.rb', line 5 def guess_code @guess_code end |
Instance Method Details
#hint? ⇒ Boolean
23 24 25 |
# File 'lib/app/entities/guess.rb', line 23 def hint? @guess_code == HINT end |
#validate ⇒ Object
16 17 18 19 20 21 |
# File 'lib/app/entities/guess.rb', line 16 def validate return if hint? @errors << failing.secret_code_length unless check_length @errors << failing.secret_code_digits_range unless check_digits_range end |