Class: Difficulty

Inherits:
BaseClass show all
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

Instance Method Summary collapse

Methods inherited from BaseClass

#valid?

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.



12
13
14
15
# File 'lib/entities/difficulty.rb', line 12

def initialize(level = :easy)
  @level = LEVELS[level.to_sym]
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



10
11
12
# File 'lib/entities/difficulty.rb', line 10

def errors
  @errors
end

#levelObject (readonly)

Returns the value of attribute level.



10
11
12
# File 'lib/entities/difficulty.rb', line 10

def level
  @level
end

Instance Method Details

#validateObject



17
18
19
# File 'lib/entities/difficulty.rb', line 17

def validate
  @errors << 'unexpected_comand' unless LEVELS.values.include? @level
end