Class: Codebreaker::Difficulty
- Defined in:
- lib/entities/difficulty.rb
Constant Summary collapse
- LEVELS =
{ easy: { attempts: 15, hints: 3, name: 'easy', id: 1 }, medium: { attempts: 10, hints: 2, name: 'medium', id: 2 }, hell: { attempts: 5, hints: 1, name: 'hell', id: 3 } }.freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
-
#initialize(level = :easy) ⇒ Difficulty
constructor
A new instance of Difficulty.
- #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(level = :easy) ⇒ Difficulty
Returns a new instance of Difficulty.
13 14 15 16 |
# File 'lib/entities/difficulty.rb', line 13 def initialize(level = :easy) @level = LEVELS[level.to_sym] @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/entities/difficulty.rb', line 11 def errors @errors end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
11 12 13 |
# File 'lib/entities/difficulty.rb', line 11 def level @level end |
Instance Method Details
#validate ⇒ Object
18 19 20 |
# File 'lib/entities/difficulty.rb', line 18 def validate @errors << 'unexpected_comand' unless LEVELS.values.include? @level end |