Class: CodebreakerGem::Difficulty
- Inherits:
-
ValidatedEntity
- Object
- ValidatedEntity
- CodebreakerGem::Difficulty
- Defined in:
- lib/app/entities/difficulty.rb
Constant Summary collapse
- DIFFICULTIES =
{ easy: { level: 'easy', attempts: 15, hints: 3 }, medium: { level: 'medium', attempts: 10, hints: 1 }, hard: { level: 'hard', attempts: 5, hints: 1 } }.freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(difficulty) ⇒ Difficulty
constructor
A new instance of Difficulty.
- #validate ⇒ Object
Methods inherited from ValidatedEntity
Constructor Details
#initialize(difficulty) ⇒ Difficulty
Returns a new instance of Difficulty.
27 28 29 30 |
# File 'lib/app/entities/difficulty.rb', line 27 def initialize(difficulty) super() @level = DIFFICULTIES[difficulty.to_sym] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/app/entities/difficulty.rb', line 5 def errors @errors end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
5 6 7 |
# File 'lib/app/entities/difficulty.rb', line 5 def level @level end |
Class Method Details
.list ⇒ Object
36 37 38 |
# File 'lib/app/entities/difficulty.rb', line 36 def self.list DIFFICULTIES.keys.map(&:to_s).map(&:capitalize) end |
Instance Method Details
#validate ⇒ Object
32 33 34 |
# File 'lib/app/entities/difficulty.rb', line 32 def validate @errors << failing.unexpected_difficulty if check_difficulty end |