# frozen_string_literal: true module AndriiCodebreaker class Difficulty include Constant attr_reader :name, :hints, :attempts def initialize(name) validate_difficulty(name) @name = name @hints = DIFFICULTY[name.to_sym][:hints] @attempts = DIFFICULTY[name.to_sym][:attempts] end def validate_difficulty(name) return DIFFICULTY[name.to_sym] if DIFFICULTY.keys.include? name.to_sym raise ArgumentError, I18n.t('game.difficulty_input_error') end end end